If I delete an element from an array with integer indices, and then apply the json_encode function to it, I get a string with a JavaScript object instead of a string with an array.
Here is a sample code:
$a = [1, 2, 3]; unset($a[0]); echo(json_encode($a)); // {"1":2,"2":3} How to get the output string with an array?
In the case of the example above, the output should be like this:
[2,3]
json_encodereturns a string. - vp_arth