开发者

How do you find out if a word is present AS A WORD in a string?

Simply put, how do you find out if the 'the' is present in the following string: 'Well lately THEre seems to be much confusion between 开发者_C百科how to use THEy're, THEre, and THEir, I don't see what THE big deal is?'

The needle capitalized for exaggeration, just trying to figure out how to return the word the is found in the string, but if the string were filled with theres, they'res, and theirs, it wouldn't find it.

Thanks


Do a regex search for /\bthe\b/.

preg_match('/\bthe\b/', $text)


search for ' the ' [extra space in the beginning and end]


What about

/* if(stristr($haystack, 'the')){

   // do something

} */

doh didn't read the question closely enough.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜