Jump to content

[SOLVED] Explode to <ul><li>


conker87

Recommended Posts

<?php
function explode_li($string) {
      $array = explode("</li>", $string);
      foreach ($array as $key => $val) {
              $array[$key] = strip_tags($val);
      }
      array_pop($array); // last element should be nothing.
      return $array
}
?>

 

Give that a try. www.php.net/strip_tags www.php.net/explode

 

EDIT: Just noticed what the question was, a different version from poco is

 

<?php

$string = "one, two, three";
function explode_tolist($string) {
      $array = explode(",", $string);
      $string = "<ul>";
     foreach ($array as $val){
             $string .= "<li>" . trim($val) . "</li>";
     }
     $string = "</ul>";
}

$exploded = explode_tolist($string);

echo $exploded;
?>

Link to comment
https://forums.phpfreaks.com/topic/57328-solved-explode-to/#findComment-283422
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.