Question: I'm pretty capable when coding PHP though I just came across a situation where I wondered if it would be possible to use `stristr` to match any value in an array inside a *SINGLE* if condition. I don't need/want a class, a dedicated function or anything super-complex nor am I doing anything complex such as trying to match special characters, I just think I may have missed something useful over at php.net.

The general notion...

```
if (stristr($search_this,$array_with_values)) {echo 'a match was found';}

```

...or what would amount to (even though this does not work)...

```
if (stristr($search_this,array('string1','string2'))) {echo 'a match was found';}

```

...I might try to find the strings 'apple','orange','banana' in a regular sentence/string.

I can define the array outside of the if condition.

My main goal is to simply not have numerous if conditions or use multiple operators such as && or ||.

So I do not want to have multiple || operators like this if possible...

```
if (
stristr($search_this_string,'string1') || 
stristr($search_this_string,'string2') || 
stristr($search_this_string,'string3')
) {echo 'a match was found';}

```

I don't mind having the array before/outside of the if condition though I want to be able to fit everything else inside of a single if condition.

Answer: 
A regular expression would definitely be best for this one. Very short, and I 'd expect fastest than anything even remotely close to the length.

```
if(preg_match('/'.implode('|', array_map('preg_quote', $needles)).'/i', $haystack)) {
    echo 'Match found!';
}

```

**Edit:** Regarding "stristr" being present on the question title... focus on the *problem*, not on a solution.
This function would do what you want, if it is an acceptable approach:

```
function substr_in_array ($str, $array, $caseSensitive = FALSE) {
  if ($caseSensitive) {
    foreach ($array as $value) if (strpos($value, $str) !== FALSE) return TRUE;
  } else {
    foreach ($array as $value) if (stripos($value, $str) !== FALSE) return TRUE;
  }
  return FALSE;
}

if (substr_in_array($search_this, $array_with_values)) {
  echo 'a match was found';
}

```

As a side note, you seem to be using `strstr()` to detect *if* a substr exists, for which you should in fact be using `strpos()` (the same applies to `stristr()` and `stripos()`)