PHP : Extend nl2br : only ONE


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

URL: http://www.giacomel.fr

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.