note 124379 deleted from function.json-encode by cmb

From: Date: Mon, 11 Nov 2019 07:25:00 +0000
Subject: note 124379 deleted from function.json-encode by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213036@lists.php.net to get a copy of this message
Note Submitter: avner at klido dot net ---- json_encode will encode array as object if the array;s keys are not sequential starting with zero $a = [0=>'a', 1=>'b', 2=>[0 => 'aa', 1 => 'c', 2 => 'dd']]; var_dump(json_encode($a)); //["a","b",["aa","c","dd"]] $b = [1=>'a', 2=>'b', 3=>[0 => 'aa', 1 => 'c', 2 => 'dd']]; var_dump(jsoon_encode($b)); // {"1":"a","2":"b","3":["aa","c","dd"]} i would expect PHP to follow the original structure or at least add a parameter to do so

« previous php.notes (#213036) next »