I have read several similar questions on here, such as this, Finding the minimum value's key in an associative array but I think my problem may be unique in that my source array is not strings as keys.
My source array looks like this,
$dealers = array(
array(
[id] => 1526,
[count] => 2
),
array(
[id] => 1518,
[count] => 5
),
array(
[id] => 1511,
[count] => 9
),
array(
[id] => 1410,
[count] => 3
)
);
I need to get the id of the smallest count value.
I have tried the following,
$low_dealer = array_keys($dealers, min($dealers));
But it appears to be returning the index of the lowest id and not count.
My next attempt was combining another function I found to find the min of the specific column,
$low_dealer = array_keys($dealers, min( array_column( $dealers, 'count' ) ));
But that returned nothing.
EDIT: Also must be able to handle multiple mins, if two or more have the same count number, need to get an array of them back so I can rand() it.
Would appreciate any tips here, thank you!