title: How to detect 4-byte characters using PHP
body: <p>I need help to detect when a string contains 4-byte characters using PHP. Is there a built in function or regex that can efficiently do this?</p>
  
  <p>I have found this article that talks about replacing, but I cannot find a working example that just detects.</p>
  
  <p><a href="https://stackoverflow.com/questions/16496554/can-php-detect-4-byte-encoded-utf8-chars">Can php detect 4-byte encoded utf8 chars?</a></p>
  
  <p>This is about as far as I got but it fails too:</p>
  
  <pre><code>$chars = str_split($term);
  foreach ($chars as $char) {
      if (strlen($char) &gt;= 4) {
          print "Found 4-byte character\n";
      }
  }
  </code></pre>