its my understanding that you wish to strip the last character of the string
not return it. Putting -1 in the length parameter will just return the last
character, it wont get rid of it....


$string = "This is the string,";
$str_length = strlen($string);

if (substr($string,0,-1) == ",") {
        //Strip
        $formatted_str = substr($string,0,str_length-1);
} else {
        //Dont strip
        //
}


That should work but I didnt test it  ;)


Regards
Jarrad Kabral



-----Original Message-----
From: Tyler Longren [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 23 April 2002 1:57 PM
To: Evan Nemerson; [EMAIL PROTECTED]
Subject: Re: [PHP] remove last character in a string


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

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

Reply via email to