egoselfaxis
asked on
Seeking a PHP code snippet that loops through multiple lines in a textarea and turns it into an unordered list
I'm looking for a PHP code snippet that loops through multiple lines in a textarea and turns it into an unordered list.
For example, users would paste the text similar to the following into a textarea (with a hard carriage return after each line):
.. and I'd like to convert it to the following -- on the fly -- using PHP:
I believe the main challenge is that I have to turn this into some kind of list or array (using the hard carriage returns as delimiters) and to then loop through that list to stiitch everything back together into an unordered list.
How would I accomplish this using PHP?
Thanks,
- Yvan
For example, users would paste the text similar to the following into a textarea (with a hard carriage return after each line):
Hand carved double wood entry doors
Wood flooring and wood detailed ceiling with custom moldings
Breakfast bar with sink, refrigerator and cabinetry
Large bedroom with views of the Intracoastal Waterway
French doors lead out to a private covered patio with fireplace
.. and I'd like to convert it to the following -- on the fly -- using PHP:
<ul>
<li>Hand carved double wood entry doors</li>
<li>Wood flooring and wood detailed ceiling with custom moldings</li>
<li>Breakfast bar with sink, refrigerator and cabinetry</li>
<li>Large bedroom with views of the Intracoastal Waterway</li>
<li>French doors lead out to a private covered patio with fireplace</li>
</ul>
I believe the main challenge is that I have to turn this into some kind of list or array (using the hard carriage returns as delimiters) and to then loop through that list to stiitch everything back together into an unordered list.
How would I accomplish this using PHP?
Thanks,
- Yvan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Excellent. Please mark my answer as the solution to close this question. Have a great day!
ASKER
- Yvan