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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -