Re: HTML Utilities

From: Date: Sat, 13 Mar 2004 21:42:07 +0000
Subject: Re: HTML Utilities
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-180358@lists.php.net to get a copy of this message
How about this: <?php function toList ( $array ) {
    $temp = '';
    foreach ( $array AS $item ) {
        if ( is_array ( $item ) ) {
            $temp .= '<ul>'.toList ( $array ).'</ul>';
        } else {
	    $temp .= '<li>'.$item.'</li>';
        }
    }
    return $temp ;
} $array = array ( 10 , 20 , array ( 30 , 40 ) ); echo toList ( $array ) ; ?> Haven't testet it but i think this should work out quite nice :) Jeff Oien wrote:
Are there any ready made utilities out there for adding HTML tags to lists? For example if I have: This Thing That Thing The Other Thing Lot More Things etc. I would like to have something that would either add <br> <li></li> (including <ul></ul> at beginning and end) or <p></p>. If there's nothing out there I'll try to do it myself but then I'll have to bother you people with questions. :) Jeff Oien


« previous php.general (#180358) next »