Re: [PHP] remove last comma in string

2006-06-09 Thread Richard Lynch

You're missing an = for the city.

substr() should have worked.

rtrim() won't work, as ',' is not whitespace.

On Thu, June 8, 2006 7:58 pm, weetat wrote:
 Hi all,

   I am using php 4.3.2 and mysql , linux.

   I have a sql statement below :

  UPDATE tbl_chassis_temp SET  country = 'Singapore',  city
 'SINGAPORE',  building = 'Tampines Central 6',  other = 'Level 03-40',


 I need to remove the last comma from sql text above.
 I have tried using substr and rtrim , without any success ?
 Anyone have any suggestion ?

 THanks
 - weetat

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] remove last comma in string

2006-06-09 Thread Paul Novitski



weetat wrote:

 I have a sql statement below :
UPDATE tbl_chassis_temp SET  country = 'Singapore',  city 
'SINGAPORE',  building = 'Tampines Central 6',  other = 'Level 03-40',

I need to remove the last comma from sql text above.
I have tried using substr and rtrim , without any success ?



At 06:10 PM 6/8/2006, Chris wrote:

How about:

$query = substr(trim($query), 0, -1);


This feels like a hack to me -- it acts blindly, assuming that just 
the comma and no extra spaces are at the end of the string.  Better I 
think to intelligently remove just those characters one wishes to remove.



At 03:00 PM 6/9/2006, Richard Lynch wrote:


rtrim() won't work, as ',' is not whitespace.


Richard, you're wrong -- read the manual.  All three functions 
trim(), ltrim(), and rtrim() allow you to append an optional list of 
characters to be trimmed:


http://php.net/trim
http://php.net/ltrim
http://php.net/rtrim

Regards,
Paul 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] remove last comma in string

2006-06-09 Thread Richard Lynch
On Fri, June 9, 2006 5:17 pm, Paul Novitski wrote:
rtrim() won't work, as ',' is not whitespace.

 Richard, you're wrong -- read the manual.  All three functions
 trim(), ltrim(), and rtrim() allow you to append an optional list of
 characters to be trimmed:

 http://php.net/trim
 http://php.net/ltrim
 http://php.net/rtrim

Yeah, those wacky PHP Devs keep adding features faster than I can
learn and remember 'em :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] remove last comma in string

2006-06-08 Thread weetat

Hi all,

 I am using php 4.3.2 and mysql , linux.

 I have a sql statement below :

UPDATE tbl_chassis_temp SET  country = 'Singapore',  city 
'SINGAPORE',  building = 'Tampines Central 6',  other = 'Level 03-40', 



I need to remove the last comma from sql text above.
I have tried using substr and rtrim , without any success ?
Anyone have any suggestion ?

THanks
- weetat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] remove last comma in string

2006-06-08 Thread D. Dante Lorenso

weetat wrote:

Hi all,

 I am using php 4.3.2 and mysql , linux.

 I have a sql statement below :

UPDATE tbl_chassis_temp SET  country = 'Singapore',  city 
'SINGAPORE',  building = 'Tampines Central 6',  other = 'Level 03-40',


I need to remove the last comma from sql text above.
I have tried using substr and rtrim , without any success ?
Anyone have any suggestion ?


http://us2.php.net/manual/en/function.trim.php
trim: 4.1.0 The optional charlist parameter was added.

$str = UPDATE tbl_chassis_temp SET  country = 'Singapore',  city 
'SINGAPORE',  building = 'Tampines Central 6',  other = 'Level 03-40', ;

$str = trim($str, ', ');
print $str;

Dante

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] remove last comma in string

2006-06-08 Thread Chris

weetat wrote:

Hi all,

 I am using php 4.3.2 and mysql , linux.

 I have a sql statement below :

UPDATE tbl_chassis_temp SET  country = 'Singapore',  city 
'SINGAPORE',  building = 'Tampines Central 6',  other = 'Level 03-40',


I need to remove the last comma from sql text above.
I have tried using substr and rtrim , without any success ?
Anyone have any suggestion ?


How about:

$query = substr(trim($query), 0, -1);

?

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php