php - How find words and strip the words after it? -


$string = 'hello world php bla bla..'; 

how keep 'hello world php', finding if string contains 'is', , remove characters after it?

i can't use substr because occurrence of 'is' not consistent, may repeatable. how catch first one?

you can use explode:

<?php  $string = 'hello world php bla bla..';  $string = explode(' ', $string);  echo $string[0];  ?> 

read more at:

http://php.net/manual/en/function.explode.php


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -