title: How to remove empty paragraph tags from string?
body: <p>I ran into a slight coding problem with WordPress template. This is the code I use in template:</p>
  
  <pre><code>&lt;?php echo teaser(40); ?&gt;
  </code></pre>
  
  <p>In my functions, I use this to strip tags and get content from allowed tags only.</p>
  
  <pre><code>&lt;?php
  function teaser($limit) {
      $content = explode(' ', get_the_content(), $limit);
      if (count($content)&gt;=$limit) {
      array_pop($content);
      $content = implode(" ",$content).'...';
      } else {
      $content = implode(" ",$content);
      }   
      $content = preg_replace('/\[.+\]/','', $content);
      $content = apply_filters('the_content', $content); 
      $content = str_replace(']]&gt;', ']]&amp;gt;', $content);
      $content = strip_tags($content, '&lt;p&gt;&lt;a&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;&lt;em&gt;&lt;strong&gt;');
      return $content;
  }
  ?&gt;
  </code></pre>
  
  <p>The problem: I use the above code to strip  tags from the content, but WordPress already puts image tags within paragraph. So the result is empty paragraph tags where images are stripped. </p>
  
  <p>Just for the sake of cleaning up my code and useless empty tags.
  My question is how to remove empty paragraph tags?</p>
  
  <pre><code>&lt;p&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Thanks a lot in advance! :)</p>