Stripping characters

Chris Hesselrode
2008-04-23 04:07:39
Stripping characters
I currently use a string such as the one below to strip the last character in my string ... however I'm now getting to a point where some of the $x variables will not have a period at the end, that I want to strip.

$x_str = substr($x, 0, -1);

How can I go about selectively removing the last character, based upon what it is?

Thanks in advance!
Veselin
2008-04-23 09:00:04
Re:
you can check the last character in the string using:

$xLen = strlen($x);
if ($x[$xLen-1]=='.') {
$x_str = substr($x, 0, -1);
} else {
$x_str = $x;
};
Reply
Title:
Your name:
Your email: (email address will not be posted on the web site)
Reply:
Verification