Sorting JSON array in PHP
How to sort field "name" in ASC and also sort by DESC order using only php?
That's what I have so far
$stud = json_encode($arr);
print_r($stud);
What are the outputs ..
[{"id":1, "name":"Some Name"},
{"id":4, "name":"Another Name"},
{"id":9, "name":"Third Name"}]
But that's what I need
[{"id":4, "name":"Another Name"},
{"id":1, "name":"Some Name"},
{"id":9, "name":"Third Name"}];
How do I sort the column of names alphabetically after json_encode()
?
+2
arunkumar
source
to share