note 124380 deleted from function.json-encode by crell

From: Date: Fri, 01 Jul 2022 19:17:19 +0000
Subject: note 124380 deleted from function.json-encode by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218825@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 (#218825) next »