Home > Archive > PHP DB > April 2004 > RE: [PHP-DB] Remove white space?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
RE: [PHP-DB] Remove white space?
|
|
| Richard Hutchins 2004-04-22, 11:30 am |
| Robert,
ltrim() or rtrim() to get rid of the whitespace if it's at the beginning or
end of the data.
strtolower() to turn the string into all lowercase characters.
Rich
> -----Original Message-----
> From: Robert Sossomon [mailto:robert@gcnorris.com]
> Sent: Thursday, April 22, 2004 10:51 AM
> To: php-db@lists.php.net; php-general@lists.php.net
> Subject: [PHP-DB] Remove white space?
>
>
> I am pulling data from a MySQL DB and I need to remove the
> whitespace on
> the variable and turn it to lowercase.
>
> <! Code Snippet>
>
> $get_items = "select * from PFS_items";
> $get_items_res = mysql_query($get_items) or die(mysql_error());
> while ($items = mysql_fetch_array($get_items_res))
> {
> $item_id = $items[id];
> $item_num = $items[item_num];
>
> <! End Code Snippet>
>
> Overtime I need to rewrite my DB loading script to handle this for me,
> but right now I need to band-aid it so that I can auto-generate pages
> and get them loaded into a catalog.
>
> Thanks!
>
> Robert
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
| |
| Miles Thompson 2004-04-22, 11:31 am |
| 1. Don't cross-post!
2. Read the string functions in the php manual. You probably don't want to
remove all white space, just trim. Have a look at
http://ca3.php.net/manual/en/function.trim.php
3. You will find a function to do exactly what you want.
Regards - Miles Thompson
At 10:51 AM 4/22/2004 -0400, Robert Sossomon wrote:
>I am pulling data from a MySQL DB and I need to remove the whitespace on
>the variable and turn it to lowercase.
>
><! Code Snippet>
>
>$get_items = "select * from PFS_items";
>$get_items_res = mysql_query($get_items) or die(mysql_error());
>while ($items = mysql_fetch_array($get_items_res))
>{
> $item_id = $items[id];
> $item_num = $items[item_num];
>
><! End Code Snippet>
>
>Overtime I need to rewrite my DB loading script to handle this for me,
>but right now I need to band-aid it so that I can auto-generate pages
>and get them loaded into a catalog.
>
>Thanks!
>
>Robert
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
|
|
|
|
|