I have a set of data in DB and I am sending it to my Android App using an API function.
I have written this in PHP.
I want to sort JSON array in alphabetical order and then send it in JSON array format.
Here is the code I have, I am not sure how or where to sort this out?
$response["categorydetails"] = array();
while ($categoryrow = mysqli_fetch_array($categorylist))
{
// temp user array
$categorydetail = array();
$categorydetail["sno"] = $categoryrow["sno"];
$categorydetail["category"] = $categoryrow["category"];
// push single product into final response array
array_push($response["categorydetails"], $categorydetail);
}
$response["success"] = 1;
$response["message"] = "Login Successful";
echo json_encode($response);
Can someone help me figure this out?
Thanks!