silkfire Posted April 19, 2011 Share Posted April 19, 2011 I need help this problem seem too tricky for me right now. I got an array with decimal numbers and behind it says Yes/No. The min() function works magically and still is able to correctly give me the lowest value. But how do i make a while loop that loops until it pops a value that is lowest and has Yes behind it? For example: Array => ('11,64|No', '209,81|Yes', '533,42|Yes', '27,90|No', '93,01|Yes') So this function should return '93,01|Yes' Link to comment https://forums.phpfreaks.com/topic/234144-find-minimum-in-array-loop-until/ Share on other sites More sharing options...
dcro2 Posted April 19, 2011 Share Posted April 19, 2011 This work? function getYesMin($arr) { sort($arr, SORT_NUMERIC); foreach($arr as $val) { $parts = explode('|', $val); if(strtolower($parts[1]) == 'yes') return $val; } } Link to comment https://forums.phpfreaks.com/topic/234144-find-minimum-in-array-loop-until/#findComment-1203401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.