Posted By

giak on 01/13/10


Tagged

pregreplace


Versions (?)

PHP : Extend nl2br : only ONE


 / Published in: PHP
 

URL: http://www.giacomel.fr

  1. // Extend nl2br PHP : only ONE <br/>
  2. function neo_replace_nl2br($texte){
  3. $pattern = '/<br\s*\/>([\n\s]*<br\s*\/>)+/si';
  4. $replacement = '<br/>';
  5. $v_texte = preg_replace($pattern, $replacement,nl2br($texte));
  6. return $v_texte;
  7. }

Report this snippet  

You need to login to post a comment.