Skip to content

Instantly share code, notes, and snippets.

@mishoo
Created July 31, 2017 08:55
Show Gist options
  • Save mishoo/48eff99a89234f153bed30bf67c280ef to your computer and use it in GitHub Desktop.
Save mishoo/48eff99a89234f153bed30bf67c280ef to your computer and use it in GitHub Desktop.
<?php
$x = [ '5' => 1, '6' => 2, '7' => 3 ];
echo json_encode($x); // outputs {"5":1,"6":2,"7":3}
$y = array_merge($x, [ '8' => 4 ]);
echo json_encode($y); // outputs [1,2,3,4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment