|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-01-16 22:06 UTC] leon dot valkenborg at blackpepper dot co dot nz
Description:
------------
json_encode will parse the PHP array as if it has string keys when a numerical key is unset.
var_dump() shows expected results. So i assume this issue is wit json_encode().
Test script:
---------------
<?
$array = array('a','b','c');
unset($array[0]);
echo json_encode($array);
?>
Expected result:
----------------
["b","c"]
Actual result:
--------------
{"1":"b","2":"c"}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 23:00:01 2025 UTC |
the bug is more that it don't behave that way before the unset because there is nothing like arrays without kyes in PHP php > $x = ['a', 'b', 'c']; php > print_r($x); Array ( [0] => a [1] => b [2] => c )