Reply to Preg_replace problem

Your name:

Reply:


Posted by matthew.davey on 04/26/07 17:20

Hi. Having a little problem with preg_replace in php.

I'm trying to convert newlines from a form input to HTML <br /> tags,
but havingnever used expression matching I can't seem to get it
working properly. I'm searching online as well but was wondering if
any of you guys could help.

I'm using this code at the moment:

$text=preg_replace('/\s/','<br>',$input);
$text=preg_replace('/<br><br>/i','<br />',$text);

($input is the input code to the function)

the problem with this is that is also converts spaces in <br /> which
is not very useful at al :(.

Any ideas how i can convert all windows and linux newline characters /
r/n | /n into <br /> using preg_replace guys? I'm probably being
stupid but i can't seem to get it woring :(

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация