Skip to content

Instantly share code, notes, and snippets.

@jjsty1e
Last active July 9, 2020 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjsty1e/9338af5321d3294d86d350fd2cad0fc9 to your computer and use it in GitHub Desktop.
Save jjsty1e/9338af5321d3294d86d350fd2cad0fc9 to your computer and use it in GitHub Desktop.
<?php
$data = [
(object)[],
(object)[]
];
echo json_encode($data) . "\n";
echo json_encode($data, JSON_FORCE_OBJECT);
/// output:
[{},{}]
{"0":{},"1":{}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment