Find if word exist in array or string PHP : <p>I am trying to find if any of the string inside an array exist in array of words.</p>

<p>For example:</p>

<pre><code>$key = ["sun","clouds"];
$results = ["Sun is hot","Too many clouds"];
</code></pre>

<p>If any of <code>$key</code> exists in <code>$results</code> to return <code>true</code></p>

<p>With below script I get the result I want but only if word in <code>$results</code> is exact like the word in <code>$key</code>.</p>

<pre><code>function contain($key = [], $results){
    $record_found = false;
    if(is_array($results)){

        // Loop through array
        foreach ($results as $result) {
             $found = preg_match_all("/\b(?:" .join($key, '|'). ")\b/i", $result, $matches);
             if ($found) {
                $record_found = true;
             }
        }

     } else {

         // Scan string to find word
         $found = preg_match_all("/\b(?:" .join($key, '|'). ")\b/i", $results, $matches);
         if ($found) {
            $record_found = true;
         }

      }

      return $record_found;

 }
</code></pre>

<p>If the word in <code>$results</code> is <code>Enjoy all year round **sunshine**</code> my function returns <code>false</code> as can not find word sun. How can I change my function to return true if string contain that string as part of word?</p>

<p>I want the word <code>sun</code> to match even with <code>sun</code> or <code>sunshine</code>.</p>

<p>TIA</p>
