JSON object always changes its sort order after conversion from PHP arrays to JSON is there any solution ?
1 Answer 1
JS objects don't have meaning to key sort order. If you need to keep the order similar to your PHP array - you can create an array with the keys (array_keys function), convert it to JSON (this will keep the order because its an array and not an object) and pass it along with the object it self, and in your JS or wherever you are parsing the badly ordered object - just use the array as the order for the object (loop over it and access the object key by the current array element).