Skip to content

Instantly share code, notes, and snippets.

@mattieb
Created April 16, 2013 14:11
Show Gist options
  • Save mattieb/5396214 to your computer and use it in GitHub Desktop.
Save mattieb/5396214 to your computer and use it in GitHub Desktop.
Why PHP sucks, volume 295: how array stupidity breaks json_encode
<?php
var_dump(json_encode(array(1, 2, 3)));
var_dump(json_encode(array(0=>1, 1=>2, 2=>3)));
var_dump(json_encode(array(1=>1, 2=>2, 3=>3)));
$a = array(1, 2, 3);
var_dump(json_encode($a));
unset($a[1]);
var_dump(json_encode($a));
@trenton42
Copy link

I can't imagine the number of things that would break if that got fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment