This is example:
$haystack = "451516178jjgsjkjjssbbziznbdkbnjv.bvkljk_isikjsksjkthisjkhkjhkjh4364765467";
$needle = "this";
I need true or false. How to do that?
I think with preg_match but I dont know how.
This is example:
$haystack = "451516178jjgsjkjjssbbziznbdkbnjv.bvkljk_isikjsksjkthisjkhkjhkjh4364765467";
$needle = "this";
I need true or false. How to do that?
I think with preg_match but I dont know how.
Try this:
$haystack = "451516178jjgsjkjjssbbziznbdkbnjv.bvkljk_isikjsksjkthisjkhkjhkjh4364765467";
$needle = "this";
$string = strpos($haystack, $needle);
if($string === false)
echo "false";
else
echo "true";
You can try strpos functionality.
Example:
$title = "this is a string123";
if ((strpos($title,'is')=== false) {
echo 'false';
else
echo 'true';
}
reference : http://php.net/manual/en/function.strpos.php
This is how you do it with regex:
$needle = "/this/";
echo preg_match($needle, $haystack);
This will return 1 one if it matches else 0