Posted By

ishkur on 07/23/08


Tagged

php paragraph convert double linebreak


Versions (?)

dnl2p


 / Published in: PHP
 

  1. <?php
  2. $text = "Here is some text.
  3.  
  4. this text is hopefully
  5. going to be cut up into
  6.  
  7. paragraph sections. and
  8. will have
  9.  
  10. paragraph tags placed
  11. around it.";
  12.  
  13. function dnl2p($array)
  14. {
  15. $array = explode("\n\n", $array);
  16. foreach($array as $paragraph)
  17. {
  18. $return .= "<p>".$paragraph."</p>\n";
  19. }
  20. return $return;
  21. }
  22.  
  23. echo dnl2p($text);
  24. ?>

Report this snippet  

You need to login to post a comment.