Forum Moderators: coopster
$match = 58;
$set = array(1,2,3,5,8,13,21,34,55,89,144,233,377,54);
foreach($set as $fib){
if($fib <= $match) {
$num = ($match - $fib);
} else {
$num = ($fib - $match);
}
$new_set[$fib] = $num;
}
$val = min($new_set);
$key = array_search($val, $new_set);
echo $key;