remove last character from string in php

Matt
October 9, 2006, 11:24 am
remove last character from string in php
I tried trim but did not work. Thnx
Veselin
October 9, 2006, 11:25 am
Re:
if you have a string $string try using

substr_replace($string ,"",-1);

it will remove tha last character from $string.
Jon
February 23, 2007, 11:29 pm
Re:
Veselin, nice response. Matt, **** job trying to answer the questin for yourself, did you even look up what trim() does? Do you program by guessing words and hoping they do what you want?
the dude
March 3, 2008, 10:01 pm
Re:
Veselin, nice response. Jon, why put Matt down, he's clearly learning. I pray that you don't pollute the world with any offspring.
Hector
May 23, 2008, 7:53 pm
Re:
Veselin, nice response. the dude, I pray that any of your offspring aren't as nosey and judgemental as you.
MyZelf
June 7, 2008, 2:45 pm
Re:
Hey, sorry, gotta make the remark: you don't have to guess words anymore!! ...that's what color syntaxing text editors are about :)

Sangili(India)
July 4, 2008, 9:19 am
Re:
I got an exact answer dude, thanks.
aravind
July 15, 2008, 9:48 pm
Re:
thanks. its really working well
Abarna
July 15, 2008, 9:50 pm
Re:
Thanks
nex
August 14, 2008, 11:19 pm
Re:
substr($string,0,-1);

removes last char..
N
October 29, 2008, 10:19 pm
Re: trim could works
Actually, trim can work. Specifically, rtrim.

echo rtrim('remove the letter a', 'a');
pradeep
November 7, 2008, 4:43 pm
Re: substr will also work
<?php
$str='pradeep';
$len=strlen($str);
$test=substr($str,0,($len-1));
echo $test;
?>
Reply
Title:
Your name:
Your email: (email address will not be posted on the web site)
Reply:
Verification