note 107616 deleted from function.json-encode by crell
| From: | crell@php.net | Date: | Thu, 30 Jun 2022 19:45:22 +0000 |
| Subject: | note 107616 deleted from function.json-encode by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218793@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster_php at colnect dot com
----
WARNING! Do not pass associative arrays if the order is important to you. It seems that while
FireFox does keep the same order, both Chrome and IE sort it. Here's a little workaround:
<?php
$arWrapper = array();
$arWrapper['k'] = array_keys($arChoices);
$arWrapper['v'] = array_values($arChoices);
$json = json_encode($arWrapper);
?>