title: PHP regex generator
body: <p>I have now got a working regex string for the below needed criteria:</p>
  
  <blockquote>
    <p>a one line php-ready regex that encompasses a number of keywords, and keyterms and will match at least one of them. </p>
  </blockquote>
  
  <p>For example:</p>
  
  <p><strong>Keyterms:</strong>  </p>
  
  <ul>
  <li><code>apple</code></li>
  <li><code>banana</code></li>
  <li><code>strawberry</code></li>
  <li><code>pear cake</code></li>
  </ul>
  
  <p>Now if any of these key terms are found then it returns true. However, to add a little more difficulty here, the <code>pear cake</code> term should be split as two keywords which must both be in the string, but need not be together.</p>
  
  <p>Example strings which should return true:</p>
  
  <ul>
  <li><code>A great cake is made from pear</code></li>
  <li><code>i like apples</code></li>
  <li><code>i like apples and bananas</code></li>
  <li><code>i like cakes made from pear and apples</code> </li>
  <li><code>I like cakes made from pears</code></li>
  </ul>
  
  <p>The working regex is:  </p>
  
  <pre><code>/\bapple|\bbanana|\bstrawberry|\bpear.*?\bcake|\bcake.*?\bpear/
  </code></pre>
  
  <p>Now I need a php function that will create this regex on the fly from an array of keyterms.  The stickler is that a keyterm may have any number of keywords within that key.  Only on of the keyterms need be found, but multiple can be present. As above all of the the words within a keyterm must appear in the string in any order.</p>