Hi,

i am trying to take a string from a text area and put it into a variable and split it by carriage returns and then add <li> to the beginning of the line and </li> to the end of a line. While putting <ul> at the beginning of the whole new string and </ul> at the end.

i have this code here:

// explode
$list = preg_split('/\r\n|\r|\n/', $method);

// iterate
$method1 = "<ul>";
foreach ($list as $item) {
  $method1 .= "<li>" . $item . "</li>";
}
$method1 .= "</ul>";

but when i use it with my form and submit it, it only does this and not each individual line:

<ul>
<li>
line1
line2
line3
</li>
</ul>

Did you not like the answer that I posted to this same question yesterday?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.