I need to sort my array by value in subarray. I have to do it in two options - desc sort and asc sort (so I need to define this param in function).
Here is my array:
array(5) {
[0]=>
array(2) {
["client_type"]=>
string(5) "buyer"
["id"]=>
string(3) "196"
}
[1]=>
array(2) {
["client_type"]=>
string(16) "seller"
["id"]=>
string(3) "206"
}
[2]=>
array(2) {
["client_type"]=>
string(16) "buyer"
["id"]=>
string(3) "206"
}
[3]=>
array(2) {
["client_type"]=>
string(16) "seller"
["id"]=>
string(3) "206"
}
[4]=>
array(2) {
["client_type"]=>
string(16) "buyer_and_seller"
["id"]=>
string(3) "206"
}
}
I want sort this array by client_type
array key (asc and desc). How I can do it? I checked this answer: PHP Sort Array By SubArray Value but it not solve my problem.
Thanks.