I think it's important to point out to new users of substr that "start" and "length" can be (and often are) a negative integer - if Start is negative, then the substring begins that many characters from the end of the string...
PHP Code:
$string = "quack.exe is a fun program";
echo substr($string,-4); //gram
and if length is negative, it leaves off that many characters.
PHP Code:
$string = "quack.exe is a fun program";
echo substr($string,0,-4); //quack.exe is a fun pro
Ever wondered how your blog headlines give you a partial entry followed by ... [Read More] ? Most likely, String Manipulation.
Bookmarks