PHP’s simple method to determine whether a string contains another string, php string
The example in this article describes PHP’s simple method to determine whether a string contains another string. Share it with everyone for your reference, the details are as follows:
When using PHP to determine whether a string contains a simple substring, we usually use the two functions strpos() or stristr(), but if the position of the string is in At index 0, that is to say at the beginning of the string to be matched, there will be a problem.
Of course we still have a solution. Here is a stupid solution, but it is easier to use. It applies to both Chinese and English punctuation marks.
The code is as follows:
function checkStr($str,$target)
{
$tmpArr = explode($str,$target);
//print_r($tmpArr);
if(count($tmpArr)>1)return true;
else return false;
}
$result = checkStr("sdfg","bsdfsldkfj");
var_dump($result);
Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP office document operation skills (including word, excel, access, ppt)", "Summary of PHP date and time usage", "php-oriented "Introduction Tutorial on Object Programming", "Summary of PHP String Usage", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"
I hope this article will be helpful to everyone in PHP programming.
Articles you may be interested in:
- php determines whether the string contains html tags
- php determines the character and the containing method attribute of the string
- Method in php to determine whether a string contains another string
- php method to check whether a string contains 7-digit GSM characters
- php function to intercept a string containing html tags Share
- php strstr search function to find whether a string contains certain characters
- php regular expression that does not contain a certain string
- php simply determines two characters Method to determine whether strings are equal
- PHP method to determine whether a string is a palindrome string
- php method to determine whether a string exists in an array element
- php Method to determine the position of a string in another string
- PHP strstr function to determine whether the string exists example code
- PHP implementation code to determine whether the string is all Chinese or contains Chinese
http://www.bkjia.com/PHPjc/1113698.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1113698.htmlTechArticlePHP’s simple method of judging whether a string contains another string, php string This article describes the simple judgment of PHP Method to determine whether a string contains another string. Share it with everyone...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn