You are here: Re: [PHP] carriage return « PHP « IT news, forums, messages
Re: [PHP] carriage return

Posted by Jochem Maas on 08/05/05 13:13

Diana Castillo wrote:
> How can I with php detect when there is a carriage return at the end of the
> text field in a mysql table?

get the data out of the DB first. stick it in $myString




$myString = "wtf I fond a carriage return - horsedrawn even.\n";
if (preg_match("#[\n|\r|\r\n]$#", $myString)) {
echo "wtf I fond a carriage return - horsedrawn even.";
}

tip: using trim() on $myString will strip a trailing CR.
tip: want to allow blank spaces after the CR, use this regexp instead.
"#[\n|\r|\r\n][ ]*$#" e.g:

$myString = "wtf I fond a carriage return - horsedrawn even.\r\n ";
if (preg_match("#[\n|\r|\r\n][ ]*$#", $myString)) {
echo "wtf I fond a carriage return - horsedrawn even.";
}


now can I have your roomkey? :-P


also if you want to know what \n and \r and \r\n are about then you might
start by searching for posts by Marco Tabini 3 days back on this list

>
>

 

Navigation:

[Reply to this 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

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