RE: [PHP] remove last character in a string

2002-04-23 Thread Ford, Mike [LSS]

 -Original Message-
 From: Evan Nemerson [mailto:[EMAIL PROTECTED]]
 Sent: 23 April 2002 04:54
 
 Why get strlen involved???
 
 $string = substr($string, 0, -1);

Why get quotes involved???

$string = substr($string, 0, -1);

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




Re: [PHP] remove last character in a string

2002-04-23 Thread Evan Nemerson

Haha you wouldn't feel that way if you saw some of MY code... ;)



On Monday 22 April 2002 20:57 pm, you wrote:
 Because I'm kinda stupid.  :)

 tyler

 - Original Message -
 From: Evan Nemerson [EMAIL PROTECTED]
 To: Tyler Longren [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Monday, April 22, 2002 10:53 PM
 Subject: Re: [PHP] remove last character in a string

  Why get strlen involved???
 
  $string = substr($string, 0, -1);
 
 
 
  --
  He is richest who is content with the least, for content is the wealth of
  nature.
 
  Socrates

-- 
Who speaks of liberty while the human mind is in chains?

Francis Wright

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




Re: [PHP] remove last character in a string

2002-04-22 Thread Rasmus Lerdorf

read php.net/substr

On Mon, 22 Apr 2002, Craig Westerman wrote:

 I have a string that ends in a comma. What is best method to remove the
 comma?
 
 Craig 
 [EMAIL PROTECTED]
 


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




Re: [PHP] remove last character in a string

2002-04-22 Thread Tyler Longren

First, you'll need to get the length of the str with the str_len() function.
After you have that, use the substr() function like Rasmus mentioned.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]

- Original Message -
From: Craig Westerman [EMAIL PROTECTED]
To: php-general-list [EMAIL PROTECTED]
Sent: Monday, April 22, 2002 10:26 PM
Subject: [PHP] remove last character in a string


 I have a string that ends in a comma. What is best method to remove the
 comma?

 Craig 
 [EMAIL PROTECTED]



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




RE: [PHP] remove last character in a string

2002-04-22 Thread Craig Westerman

Wouldn't it be better to check to see if charicater is indeed a comma before
removing it?

I was guessing eregi_replace would be the way to go.

Am I thinking wrong?

Craig 
[EMAIL PROTECTED]


First, you'll need to get the length of the str with the str_len() function.
After you have that, use the substr() function like Rasmus mentioned.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]


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




Re: [PHP] remove last character in a string

2002-04-22 Thread Evan Nemerson

Why get strlen involved???

$string = substr($string, 0, -1);



-- 
He is richest who is content with the least, for content is the wealth of 
nature.

Socrates

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




Re: [PHP] remove last character in a string

2002-04-22 Thread Rasmus Lerdorf

No you don't.  You should go read the substr() docs as well:

substr($str,0,-1);

-Rasmus

On Mon, 22 Apr 2002, Tyler Longren wrote:

 First, you'll need to get the length of the str with the str_len() function.
 After you have that, use the substr() function like Rasmus mentioned.
 
 Tyler Longren
 Captain Jack Communications
 www.captainjack.com
 [EMAIL PROTECTED]
 
 - Original Message -
 From: Craig Westerman [EMAIL PROTECTED]
 To: php-general-list [EMAIL PROTECTED]
 Sent: Monday, April 22, 2002 10:26 PM
 Subject: [PHP] remove last character in a string
 
 
  I have a string that ends in a comma. What is best method to remove the
  comma?
 
  Craig 
  [EMAIL PROTECTED]
 
 
 
 


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




Re: [PHP] remove last character in a string

2002-04-22 Thread Tyler Longren

Yeah, I thought about that and said to myself That's not right.  But I had
already clicked the Send button and the message was no longer in my
outbox.  :)

tyler

- Original Message -
From: Rasmus Lerdorf [EMAIL PROTECTED]
To: Tyler Longren [EMAIL PROTECTED]
Cc: Craig Westerman [EMAIL PROTECTED]; php-general-list
[EMAIL PROTECTED]
Sent: Tuesday, April 23, 2002 12:04 AM
Subject: Re: [PHP] remove last character in a string


 No you don't.  You should go read the substr() docs as well:

 substr($str,0,-1);

 -Rasmus

 On Mon, 22 Apr 2002, Tyler Longren wrote:

  First, you'll need to get the length of the str with the str_len()
function.
  After you have that, use the substr() function like Rasmus mentioned.
 
  Tyler Longren
  Captain Jack Communications
  www.captainjack.com
  [EMAIL PROTECTED]
 
  - Original Message -
  From: Craig Westerman [EMAIL PROTECTED]
  To: php-general-list [EMAIL PROTECTED]
  Sent: Monday, April 22, 2002 10:26 PM
  Subject: [PHP] remove last character in a string
 
 
   I have a string that ends in a comma. What is best method to remove
the
   comma?
  
   Craig 
   [EMAIL PROTECTED]
  
 
 
 



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




Re: [PHP] remove last character in a string

2002-04-22 Thread Tyler Longren

Because I'm kinda stupid.  :)

tyler

- Original Message -
From: Evan Nemerson [EMAIL PROTECTED]
To: Tyler Longren [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, April 22, 2002 10:53 PM
Subject: Re: [PHP] remove last character in a string


 Why get strlen involved???

 $string = substr($string, 0, -1);



 --
 He is richest who is content with the least, for content is the wealth of
 nature.

 Socrates



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




RE: [PHP] remove last character in a string

2002-04-22 Thread Matthew Walker

Actually, if he uses a negative index in substr(), he doesn't need to
know the length of the string.

Matthew Walker
Senior Software Engineer
ePliant Marketing
 

-Original Message-
From: Tyler Longren [mailto:[EMAIL PROTECTED]] 
Sent: Monday, April 22, 2002 9:29 PM
To: Craig Westerman; php-general-list
Subject: Re: [PHP] remove last character in a string

First, you'll need to get the length of the str with the str_len()
function.
After you have that, use the substr() function like Rasmus mentioned.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]

- Original Message -
From: Craig Westerman [EMAIL PROTECTED]
To: php-general-list [EMAIL PROTECTED]
Sent: Monday, April 22, 2002 10:26 PM
Subject: [PHP] remove last character in a string


 I have a string that ends in a comma. What is best method to remove
the
 comma?

 Craig 
 [EMAIL PROTECTED]



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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.345 / Virus Database: 193 - Release Date: 4/9/2002
 

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