json_decode function takes json encoded straing and converted to php variable. this function works only for UTF-8 encoded string.
for Example check the below code
1 2 3 4 5 6 7 |
<?php $json = '{"v1":1,"v2":2,"v3":3,"v4":4,"v5":5}'; var_dump(json_decode($json)); var_dump(json_decode($json, true)); ?> |
object(stdClass)#1 (5) {
[“v1”]=> int(1)
[“v2”]=> int(2)
[“v3”]=> int(3)
[“v4”]=> int(4)
[“v5”]=> int(5)
}
array(5) {
[“v1”]=> int(1)
[“v2”]=> int(2)
[“v3”]=> int(3)
[“v4”]=> int(4)
[“v5”]=> int(5)
}