I got a object like this: {"1":"FFS","2":"S"}
, and I use json_decode
function to convert it into an array, but I am not success with it. It becomes the array like this: {"FFS", "S"}, but missing the {"1", "2"}, Can I convert it to become a dict or something, that I can access both value? Thanks.
$myjsonobject = json_decode('{"1":"FFS","2":"S"}');
Should working. Try: print_r($myjsonobject);
to validate.
Its working.
use true
param, to convert object to associative array for json_decode(), like do:
$str = '{"1":"FFS","2":"S"}';
echo "<pre>"; print_r(json_decode($str, true));
gives::
Array
(
[1] => FFS
[2] => S
)