Page 1 of 1

Character String Question

Posted: Mon Jan 24, 2005 2:08 pm
by Stelios
Hi everybody,

Is there any way I can echo data from a mysql database without displaying the last 4 characters of the string?

Thanks! :)

Posted: Mon Jan 24, 2005 2:15 pm
by feyd
mysql has a function called SUBSTRING() which can be used with their CHARLENGTH() functions.. there are similar functions in php as well: substr() and strlen()

Posted: Mon Jan 24, 2005 2:26 pm
by timvw
don't even need strlen, just feed substr with a negative length, fe:

Code: Select all

$str = substr($str, 0, -4);