I have a textarea form field where users will put URL's separated by a new line. Would it be possible to wrap each line from this textarea field with < li > tags?
So I would need the output from the field to be something like this:
<li>some.url.com</li>
<li>some.url.com</li>
<li>some.url.com</li>
<li>some.url.com</li>
<li>some.url.com</li>
Does anyone know who to achive this with PHP please?
$textareaData = '<li>'.str_replace("\n","</li>\n<li>",trim($textareaData,"\n")).'</li>';
EDIT
Modified to get rid of all blank lines as well:
$textareaData = '<li>'.str_replace(array("\r","\n\n","\n"),array('',"\n","</li>\n<li>"),trim($textareaData,"\n\r")).'</li>';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With