Re: check for \n
| From: | Jason Wong | Date: | Mon, 18 Nov 2002 20:41:07 +0000 |
| Subject: | Re: check for \n | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-124972@lists.php.net to get a copy of this message | ||
On Tuesday 19 November 2002 03:37, John Taylor-Johnston wrote:
> Like I have a clue :)
>
> I want to convert some fields from TEXT to VARCHAR(255).
> (Going from a textarea to an input type=text)
> I've checked the length of each $mydata->ST, so I won't be losing data.
> What I am worried about is losing data if there are \n in any of the
> fields.
>
> How do I check to see if a \n exists in $mydata->ST in my WHILE statement?
>
> $sql = 'SELECT id,ST FROM ccl.ccl_main';
> ...
> $news = mysql_query($sql);
> while ($mydata = mysql_fetch_object($news))
> {
> if ???????$mydata->ST?????????
> echo "$mydata->id - $mydata->ST<hr>";
> }
Use strstr() with "\n" as the needle. Check out the "String functions"
chapter, lots more goodies there.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
To program is to be.
*/