php - Get only the next 6 characters after a word -
i have string:
$string = 'foo bar php haystack needle'
and want next 6 characters after php , get:
haysta
how can that?
greetings
you have find position of 'php' , add substr() on position +3 (for skipping 'php' itself):
$needle = 'php'; $str = substr($string, strpos($string, $needle) + strlen($needle), 6); the third parameter (6) length of substring want.
Comments
Post a Comment