PHP string lookup and matching in PHP is used to find or match or locate a lot of functions, they all have different meanings. This is just about using more strstr,stristr. The latter and the former function, the return values are the same, but not case-sensitive.
PHP Tutorial string Find and Match
There are very many functions in PHP that are used to find or match or locate, and they all have different meanings. This is just about using more strstr,stristr. The latter and the former function, the return values are the same, but not case-sensitive.
Strstr ("Female string", "substring") is used to find the position where the substring first appears in the parent string, and returns the portion of the parent string from the beginning of the substring to the end of the parent string. Like what
Echo strstr ("ABCDEFG", "E"); Will output "EFG"
If no substring is found, NULL is returned. Because it can be used to determine whether a string contains another string:
$needle = "Iwind";
$str = "I love Iwind";
if (Strstr ($str, $needle))
{
echo "Inside is Iwind";
}
Else
{
echo "There is no iwind";
}
Will output "There's iwind inside."
Preg_match Regular
Preg_match compatible Regular expression syntax B stands for Word boundaries
So: The following should be possible???
$a = "TEST,ADMIN,ABC";
$b = "TE";
$exist =preg_match ("/b{$b}b/", $a);
if ($exist)
{
echo "exists";
}else
{
echo "does not exist";
}
Take a look at the relevant instructions
int Preg_match (string pattern, string subject [, array matches [, int flags]]);
Preg_match () returns the number of times that pattern matches. Either 0 times (no match) or 1 times, because Preg_match () stops searching after the first match. Preg_match_all () Instead, it searches until the end of subject. If error Preg_match () returns false.
Example:
$a = "Abcdefgabcdefaaag";
Preg_match (' |abc ([a-z]+) G|isu ', $a, $out 1);
Preg_match_all (' |abc ([s]+) G|isu ', $a, $out 2);
echo "
";
Print_r ($out 1);
Print_r ($out 2);
echo "
";
?>
notation: When using double quotation marks and single quotation marks are different
Preg_match_all ("/href=" (. *) "/isu", $contents, $out);
Preg_match_all (' |href= ' (. *) "|isu", $contents, $out);
?>
http://www.bkjia.com/PHPjc/445410.html www.bkjia.com true http://www.bkjia.com/PHPjc/445410.html techarticle PHP string lookup and matching in PHP is used to find or match or locate a lot of functions, they all have different meanings. This is just about the more strstr,stristr. The latter and the former ...