What function should I use if I want to print the first 50 characters from a string?
I know that substr works the other way around, it takes out of the string the first X numbers of characters, but I can not find the function that lets me KEEP them.
Thanks to all
first characters of a string
Moderator: General Moderators
-
andresbezem
- Forum Newbie
- Posts: 2
- Joined: Wed May 11, 2005 10:18 pm
substr() works the way you want it to eg.
Thus all you need to do is:
Code: Select all
echo substr('abcdef', 0, 3); // will print 'abc'Code: Select all
echo substr($string, 0, 50);