note 51499 added to function.nl2br

From: Date: Fri, 01 Apr 2005 12:54:56 +0000
Subject: note 51499 added to function.nl2br
Groups: php.notes 
Request: Send a blank email to php-notes+get-87316@lists.php.net to get a copy of this message
here is the CSS friendly version, called nl2li_css() Inputs a param css_class (default ="none") and pass it as class of All <li> List Items. <? function nl2li_css($str,$css_class = "none",$ordered = 0, $type = "1") { //check if its ordered or unordered list, set tag accordingly if ($ordered) { $tag="ol"; //specify the type $tag_type="type=$type"; } else { $tag="ul"; //set $type as NULL $tag_type=NULL; } // add ul / ol tag // add tag type // add first list item starting tag - use css class // add last list item ending tag $str = "<$tag $tag_type><li class=\"$css_class\">" . $str ."</li></$tag>"; //replace /n with adding two tags // add previous list item ending tag // add next list item starting tag - use css class $str = str_replace("\n","</li><br />\n<li class=\"$css_class\">",$str); //spit back the modified string return $str; } ?> Suggestions welcome again :) ---- Manual Page -- http://www.php.net/manual/en/function.nl2br.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51499 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51499&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51499&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51499&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51499&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51499&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51499&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87316) next »