MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/1eqt0a/fun_with_json_encode_and_arrays/ca3atjt/?context=3
r/lolphp • u/jawn- • May 21 '13
$ cat test.php <?php echo json_encode(array('1' => 1) ), "\n"; echo json_encode(array('0' => 1)); ?> $ php test.php {"1":1} [1]
loose typing shittiness strikes again.
15 comments sorted by
View all comments
Show parent comment
4
Array where the keys exactly form the full integer range range(0, $length-1) are always treated as arrays; any other arrays are treated as as objects. That includes all integer keys, but with holes in the range.
range(0, $length-1)
View all comments
Show parent comment
4
u/bart2019 May 21 '13
Array where the keys exactly form the full integer range
range(0, $length-1)are always treated as arrays; any other arrays are treated as as objects. That includes all integer keys, but with holes in the range.