 <p><strong>This works, please see results below: (Value must be present in both array to return true.</strong></p> <pre><code> $result = true; $string1 = '43'; $string = str_split($string1); $example1 = array('num1' =&gt; 1, 'num2' =&gt; 2, 'num3' =&gt; 3, 'num4' =&gt; 4, 'num5' =&gt; 5); $example2 = array('num1' =&gt; 5, 'num2' =&gt; 4, 'num3' =&gt; 3); foreach ($string as $st) { if((in_array($st, $example1) &amp;&amp; in_array($st, $example2)) &amp;&amp; $result == true){ $result = true; //true } else { $result = false; } } if($result == true){ echo 1; //true } else { echo 0; //false } exit; //Test Results: //$string1 = '12'; //result 0 //$string1 = '34'; //result 1 //$string1 = '55'; //result 1 //$string1 = '43'; //result 1 </code></pre>