PHP Object conversion question
- by karlthorwald
I am converting from JSON to object and from object to array. It does not what I expected, can you explain to me?
$json = '{"0" : "a"}';
$obj = json_decode($json);
$a = (array) $obj;
print_r($a);
echo("a0:".$a["0"]."<br>");
$b = array("0" => "b");
print_r($b);
echo("b0:".$b["0"]."<br>");
The output here is:
Array ( [0] => a ) a0:
Array ( [0] => b ) b0:b
I would have expected a0:a at the end of the first line.