S
S
semki0962016-04-26 12:16:49
PHP
semki096, 2016-04-26 12:16:49

What is my mistake when manipulating json?

A classic example that works

<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json, true));
?>

Result
array(5) {
    ["a"] => int(1)
    ["b"] => int(2)
    ["c"] => int(3)
    ["d"] => int(4)
    ["e"] => int(5)
}

It doesn't work for me - I do it like this
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
$a = (json_decode($json, true));
print_r ($a)
?>

I get the result without quotes
Array ( [a] => 1 [b] => 2 [c] => 3 [d] => 4 [e] => 5 )

Why in my case there are no quotes after json_decode in the array?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question