Answers for "php string in string"

PHP
65

str_includes php

$myString = 'Hello Bob how are you?';
if (strpos($myString, 'Bob') !== false) {
    echo "My string contains Bob";
}
Posted by: Guest on August-06-2019
5

string contains php

$a = 'How are you?';

if (strpos($a, 'are') !== false) {
    echo 'true';
}
Posted by: Guest on October-18-2020
1

php needle haystack

//Find the position of the first occurrence of a substring in a string
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);
Posted by: Guest on May-08-2020
0

like %% inside the string php

strpos('STRING', 'SEARCH_ITEM');

--------------OR--------------------
  
preg_match('~' . preg_quote('.SEARCH_ITEM.', '~') . '~', 'STRING');
Posted by: Guest on September-27-2020

Browse Popular Code Answers by Language