Reputation: 13061
i have an array like:
Array([0]=>array('field1'=>aNumber,'field2'=>'something'),
[1]=>array('field1'=>aNumber,'field2'=>'something'),
[2]=>array('field1'=>aNumber,'field2'=>'something'),
[3]=>array('field1'=>aNumber,'field2'=>'something'));
I have to get the index of array that has min the field aNumber
..
For example:
Array([0]=>array('field1'=>10,'field2'=>'something'),
[1]=>array('field1'=>3,'field2'=>'something'),
[2]=>array('field1'=>100,'field2'=>'something'),
[3]=>array('field1'=>9,'field2'=>'something'));
the index i want is 1
.
I know is possible using a loop and some if storing the iterate index.. but i want to know if there is some php function that shortens the algorithm
how can i do? thanks!!!
Upvotes: 0
Views: 528
Reputation: 2790
As I know there is no built-in function like this. But you can use other functions with callbacks .. array_walk, array_filter
(And a built-in function will probably do same as you will do with a loop and iterate through the items of your array)
Upvotes: 1