Posted By

iloveitaly on 12/19/10


Tagged

strip trim paragraph tag ckeditor


Versions (?)

Trim Empty Paragraph Tags at Beginning & End of String


 / Published in: PHP
 

Useful for preparing content generated by CKEditor

  1. function paragraph_trim($content) {
  2. $result = preg_replace('!(^(\s*<p>(\s|&nbsp;)*</p>\s*)*|(\s*<p>(\s|&nbsp;)*</p>)*\s*\Z)!em', '', $content);
  3. return $result === NULL ? $content : $result;
  4. }

Report this snippet  

You need to login to post a comment.