while($row=mysql_fetch_array($result)) { $check = strpos($text,$row[0]); if ($check != false) { $blocked = true; $reason = $row[1]; } else { $blocked = "nomatch"; } } if($blocked == true) { return $reason; } else { return "nomatch"; }