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

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -