title: How to filter html characters?
body: <p>I have a question regarding the <code>filter</code></p>
  
  <p>I have the following:</p>
  
  <p><code>$htmlData</code> contains user input <code>html</code> string and it is like</p>
  
  <pre><code>$htmlData = array('&lt;em&gt;test&lt;/em&gt;', 'text here','\n')
  
  //I use htmlspecialchars function and want to filter \n out and save it to DB.
  
         $texts = htmlspecialchars($htmlData[$i]);
  
          if(!empty($texts) &amp;&amp; $text != '\n'){
               echo $text;   //I still see '\n' here for some reason.
           }
  </code></pre>
  
  <p>I don't want to save <code>'\n'</code> to DB because it will just be blank in <code>DB</code>. Are there anyway to prevent this? Thanks for the help!</p>