Reputation: 2018
I have variable x and I want to see if it contains a string like hs
even though the value may be cug hs ib ap
. Can anybody help me figure this out? Thanks!
Upvotes: 0
Views: 120
Reputation: 14489
Either strpos() or stripos() (depending on whether you're interested in case sensitivity).
http://php.net/manual/en/function.strpos.php
Upvotes: 1
Reputation:
You could use substr_count
.. http://php.net/substr_count or strpos
, http://php.net/strpos
Upvotes: 1
Reputation: 29508
You could use strpos
if (strpos($haystack, $needle) !== false) {
echo "the string '{$needle}' was found within '{$haystack}'";
}
Upvotes: 1
Reputation:
if(strpos($big_string, $sub_string) !== false)
{
// $big_string contains $sub_string
}
Upvotes: 1