$current = 1; $max = count($array); while($current<=$max) { if($value == $array["f".$current]) { echo $array["f".$current]; } $current++; }