Checking for the best way to trim a string. How to trim n characters from a string in PHP?
May be I need the first n characters, sometimes I need the a th character to z th character, otherwise the last n characters.
Which is the best(hope the fastest) way to trim a string to a specific number of characters?
Actually, looking for some combinations of PHP string functions.
Working with regular expressions doesn't felt much comfortable.
UPDATE:
For eg. from a string like "The quick brown fox jumps over the lazy dog.", take:
- The first
n=>5characters:"The q" - Substring from
a=>5th character toz=>12th character:"quick br" - The last
n=>5characters:" dog."
First $n characters:
Substring from $a=>5th character to $z=>12th character: "quick br"
Last n characters:
http://php.net/substr