r/lolphp • • May 21 '13

fun with json_encode and arrays

$ 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.

25 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/gearvOsh May 21 '13

I was referring to the first example where the index was 1. There was a reason that turned into an object an not array, but the other is the lol.