Answer the question
In order to leave comments, you need to log in
How to return the array with the smallest value?
there is such an array
$arr = [
[
"window" => 01,
"services" => "Asd",
"clients_count" => 4
],
[
"window" => 02,
"services" => "Asd",
"clients_count" => 3
]
];
[
"window" => 02,
"services" => "Asd",
"clients_count" => 3
]
Answer the question
In order to leave comments, you need to log in
check if the bootstrap.min.js script is included
, this method is there
function sort_my_arr($a, $b){
return ($a['clients_count'] < $b['clients_count']) ? -1 : 1;
}
usort($arr, 'sort_my_arr');
array_shift($arr);
<?php
$arr = [
[
"window" => 01,
"services" => "Asd",
"clients_count" => 4
],
[
"window" => 02,
"services" => "Asd",
"clients_count" => 3
]
];
usort($arr, function($a, $b){
return $a['clients_count'] > $b['clients_count'];
});
print_r($arr[0]);
Array ( [window] => 2 [services] => Asd [clients_count] => 3 )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question