- Intent
- Replace loops with named function
- Motivation
- find the best value in an array
- Implementation
- A simple loop over the array, keeping track of the best element value and index
- Examples
function find_best($better, $coll) { foreach($coll as $key=>$value) { if( is_null($best) || $better($value,$best[1]) ) { $best = array($key, $value); } } return $best; }