Reverse key value array in JSON (PHP) -
i have key value array in php this
[1]=>"something" [2]=>"somethingelse" [4]=>"this"
now export json, reverse array, keep indexes. json format like
{ "4":"this", "2":"somethingelse" "1":"something" }
is there easy way accomplish (without parsing json manually)?
$reverse = array_reverse($array, true); $json = json_encode ($reverse);
Comments
Post a Comment