Answers for "php if string like"

PHP
65

php string contains substring

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