I am using laravel and want to sort this array based on ['messages'] "updated_at" field. The array should show latest message on top. I tried array_multisort( array_column($yourArray, "price"), SORT_ASC, $yourArray ) but didn't work.
Here is my multidimensional array which I want to sort by date.
Array
(
[current_page] => 1
[data] => Array
(
[0] => Array
(
[id] => 236
[user] => Array
(
[id] => 91
[email] => [email protected]
[updated_at] => 2020-04-29 09:28:26
)
[messages] => Array
(
)
)
[1] => Array
(
[id] => 235
[description] => demo3
[user] => Array
(
[id] => 91
[email] => [email protected]
[updated_at] => 2020-04-29 09:28:26
)
[messages] => Array
(
[0] => Array
(
[id] => 95
[message] => Pickup message test
[user_id] => 35
[created_at] => 2020-04-28 12:28:18
[updated_at] => 2020-04-28 12:28:18
)
)
)
[2] => Array
(
[id] => 215
[description] => Testing for messages
[user] => Array
(
[id] => 35
[email] => [email protected]
[updated_at] => 2020-01-26 17:34:35
)
[messages] => Array
(
[0] => Array
(
[id] => 88
[message] => Testing for the message if not sent by business first.
[user_id] => 35
[created_at] => 2020-04-28 12:15:14
[updated_at] => 2020-04-28 12:15:14
)
[1] => Array
(
[id] => 90
[message] => Looks good.
[user_id] => 69
[created_at] => 2020-04-28 12:15:45
[updated_at] => 2020-04-28 12:15:45
)
)
)
)
)
How can I achieve this?