Page 1 of 1

cut off last character of strinf

Posted: Mon Oct 30, 2006 12:28 am
by potato
hellow,

im looking for a way to cut off the last character of a string.
the string is an array, en ends with a comma.
Thats what i want to cut off, the comma.
Anyone knwos how?

friendly greetz,
tom

Posted: Mon Oct 30, 2006 12:34 am
by itsmani1
use substr() funcion

Posted: Mon Oct 30, 2006 1:18 am
by potato
ok, it works. Thank you very much

here's the code for if anyone has the same problem:


Code: Select all

$pics = substr ($pics, 0, -1);
note that the -1 stands for minus 1 character at the end of the string.

So if your string is
this is my string

the result would be
this is my strin

if you want to cut 2 character, replmace the -1 with -2

Posted: Mon Oct 30, 2006 5:40 am
by Jenk
you can also use rtrim($string, ',');