For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2004 > 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 Remove white space?
Robert Sossomon

2004-04-22, 11:30 am

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
Torsten Roehr

2004-04-22, 11:31 am

"Robert Sossomon" <robert@gcnorris.com> wrote in message
news:022101c42879$472334e0$6601010a@root
2...
> 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


Use trim() to remove white space at the beginning and end of the string and
strtolower() to convert to lower case.

Regards, Torsten
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com