[PHP] last three characters of a string

2001-04-09 Thread Joseph Bannon

I need to examine the last 3 characters of a string. Is there code that does
that?

J




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] last three characters of a string

2001-04-09 Thread David Robley

On Tue, 10 Apr 2001 12:18, Joseph Bannon wrote:
 I need to examine the last 3 characters of a string. Is there code that
 does that?

 J

You can extract them with substr - there are examples in the docs which 
demonstrate the use of negative start parameters to work backwards from 
the end of a string. You might want to trim the string first if you don't 
want any whitespace of EOL characters.

-- 
David Robley| WEBMASTER  Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet| http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] last three characters of a string

2001-04-09 Thread Jack Dempsey

echo "last 3 chars are " . substr($string,-3);


Joseph Bannon wrote:
 
 I need to examine the last 3 characters of a string. Is there code that does
 that?
 
 J
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]