i have below json code
{"1":1,"5":1}
when decode above json got object array using below php statement.
$array_val = (array)json_decode($price);
i got below array.
array ( [1] => 1 [5] => 1 )
but below statement not work
echo $array_val[1];
the below error occurred.
undefined offset: 1
how resolve issue?
try demo
php
$json = '{"1":1,"5":1}'; $array_val=json_decode($price, true); echo $array_val[1];
output :
1
Comments
Post a Comment