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]
|