开发者

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

开发者 https://www.devze.com 2023-01-27 13:56 出处:网络
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 se

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

精彩评论

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

关注公众号