php - Sort the big array according to the value of another array which is inside the big array -


     {  "result": true,               "users": [{                             "id": 11,                        "expected_count": 13,                     "user_id": 1,                        "event_id": 2,                      "user": {                                "id": 1,                          "name": "moiz jamali"                             }              },          {                   "id": 12,                "expected_count": 12,             "user_id": 2,             "event_id": 2,                   "user": {                              "id": 2,                         "name": "juzer samiwala"                    }           }]  } 

above output of big array ('users').

what want sort big array ('users') according name value inside small array ('user') in php.

can please me this?

thank you.

you can use usort strcmp this. this:

$bigarray = ["result" => true, "users" => [     "id" => 11,     "expected_count" => 13,     "user_id" => 1,     "event_id" => 2,     "user" => [         "id" => 1,         "name" => "moiz jamali"     ],     ... other users ]];  usort($bigarray['users'], function ($a, $b) {     return strcmp($a['user']['name'], $b['user']['name']); }); 

Comments

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

html - Not able to access next element of an array javascript -