Hi,

How would i have a text box where each new line is a bullet list.

<ul>
<li>method line 1</li>
<li>method line 2</li>
</ul>

Can i extract the HTML code tags with the text and insert it into a database with the code and text? So it can be accessed later from the database.

If you want to take plain text from a textarea, and treat each new line as a separate bullet point, you could store the plain text in the database, and then parse the content as follows when retrieving it:

<?php $bullet_points = explode("\n", $plain_text); ?>

<ul>
<?php foreach($bullet_points as $bullet_point): ?>
    <li><?php echo $bullet_point; ?></li>
<?php endforeach; ?>
</ul>

If you're using this on a regular basis, you could wrap the functionality into a function.

Is this what you meant?
R.

Hi,

That is kind of what i want. But can i parse the content before sending it to the database so that it has the tags inside the database?

You can, but it's worth considering whether you will need to edit the list after it's been inserted into the database. If you do, then it would be more difficult to work around the HTML tags.

Anyway, to parse it before inserting:

$list = '<ul><li>' . implode('</li><li>', explode("\n", $plain_text)) . '</li></ul>';

R

commented: good point wrt tags in DB +14