title: Extract characters occurring before one of several forbidden characters
body: <p>I want to discard all remaining characters in a string as soon as one of several unwanted characters is encountered.</p>
  <p>As soon as a blacklisted character is encountered, the string before that point should be returned.</p>
  <p>For instance, if I have an array:</p>
  <pre><code>$chars = array(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;);
  </code></pre>
  <p>How would I go through the following string...</p>
  <pre><code>log dog hat bat
  </code></pre>
  <p>...and end up with:</p>
  <pre><code>log dog h
  </code></pre>