I have one array that is stored in one variable. The array is as follows:
Array
(
[0] => Array
(
[employee_name] => Amit
[today_date] => 2018-01-11
)
[1] => Array
(
[employee_name] => Amit
[today_date] => 2018-01-09
)
[2] => Array
(
[employee_name] => Amit
[today_date] => 2018-01-10
)
[3] => Array
(
[employee_name] => GURVINDER
[today_date] => 2018-01-11
)
[4] => Array
(
[employee_name] => GURVINDER
[today_date] => 2018-01-10
)
)
I did with sorting the array in ascending order with employee_name
, which works very well with this code:
$attendances = "above array";
uasort($attendances, function($a, $b) {
return strcmp($a["employee_name"], $b["employee_name"]);
});
Now I want everyone employee_name
to be incremental, and everyone employee_name
today_date
also to be in ascending order. My expected result is as follows:
Array
(
[0] => Array
(
[employee_name] => Amit
[today_date] => 2018-01-09
)
[1] => Array
(
[employee_name] => Amit
[today_date] => 2018-01-10
)
[2] => Array
(
[employee_name] => Amit
[today_date] => 2018-01-11
)
[3] => Array
(
[employee_name] => GURVINDER
[today_date] => 2018-01-10
)
[4] => Array
(
[employee_name] => GURVINDER
[today_date] => 2018-01-11
)
)
Please help me solve this problem. For some reason, I will not use the SQL query. Thanks in advance.
source
share