title: Unable to strip HTML tags from multibyte input
body: <p>I have a function which assist to strip out HTML tags from input as below.</p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>function strip_html_tags2( $str ) 
      {
          $var_search = array(
              // Remove invisible content
              '@&lt;head[^&gt;]*?&gt;.*?&lt;/head&gt;@siu',
              '@&lt;style[^&gt;]*?&gt;.*?&lt;/style&gt;@siu',
              '@&lt;script[^&gt;]*?.*?&lt;/script&gt;@siu',
              '@&lt;object[^&gt;]*?.*?&lt;/object&gt;@siu',
              '@&lt;embed[^&gt;]*?.*?&lt;/embed&gt;@siu',
              '@&lt;applet[^&gt;]*?.*?&lt;/applet&gt;@siu',
              '@&lt;noframes[^&gt;]*?.*?&lt;/noframes&gt;@siu',
              '@&lt;noscript[^&gt;]*?.*?&lt;/noscript&gt;@siu',
              '@&lt;noembed[^&gt;]*?.*?&lt;/noembed&gt;@siu',
              // Add line breaks before and after blocks
              '@&lt;/?((address)|(blockquote)|(center)|(del))@iu',
              '@&lt;/?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
              '@&lt;/?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
              '@&lt;/?((table)|(th)|(td)|(caption))@iu',
              '@&lt;/?((form)|(button)|(fieldset)|(legend)|(input))@iu',
              '@&lt;/?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
              '@&lt;/?((frameset)|(frame)|(iframe))@iu',
          );
          $var_replace = array(
              ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
              "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
              "\n\$0", "\n\$0",
          );
          //$str = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
          $str = preg_replace("/&amp;#?[a-z0-9]+;/i"," ", $str);
          $str = preg_replace( $var_search, $var_replace, $str );
          return strip_tags( $str );
      }
  </code></pre>
  
  <p>It's not working while I try to use on the content below and the result will be an empty string.</p>
  
  <pre><code>&lt;p&gt;If you’ve had a website up since at least the beginning of the year...&lt;/p&gt;
  </code></pre>
  
  <p>It probably caused by the single quote but I have no idea on how to solve this. </p>
  
  <p>Try copy and paste it into demo page below.</p>
  
  <p><a href="http://generate-password.net/test/" rel="nofollow">Demo</a></p>
  
  <p>Any advice will be greatly appreciated.</p>