homepage Welcome to WebmasterWorld Guest from 54.161.147.106
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
preg replace question
alphacooler




msg:3114321
 5:13 pm on Oct 9, 2006 (gmt 0)

I've got a preg_replace that tosses <li></li>'s around every new line. I know it works on windows machines, but I know the code doesn't account for any other systems.

$body = preg_replace("/\n/","</li><li>",$body);

What should I change here?

Thanks!

 

eelixduppy




msg:3114351
 5:31 pm on Oct 9, 2006 (gmt 0)

The solution didn't work from your last thread [webmasterworld.com]?

Here's a full example:

<?php
if(isset($_POST['text']))
{
$pattern = "/^(.+)$/m";
echo '<ul>';
echo preg_replace($pattern,"<li>$1</li>",$_POST['text']);
echo '</ul>';
}
?>
<form method="post">
<textarea name="text"></textarea>
<input type="submit" />
</form>

alphacooler




msg:3114390
 5:50 pm on Oct 9, 2006 (gmt 0)

Perfect! Thanks.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved