无涯教程-PHP - preg_match()函数

preg_match() - 语法

int preg_match (string pattern, string string [, array pattern_array], [, int $flags [, int $offset]]]);

preg_match()函数在字符串中搜索pattern,如果存在pattern,则返回true,否则返回false。

如果提供了可选的输入参数pattern_array,则pattern_array将包含搜索模式中包含的子模式的各个部分(如果适用)。

preg_match() - 返回值

  • 如果存在,则返回true,否则返回false。

preg_match() - 示例

php
   $line="Vi is the greatest word processor ever created!";
   //perform a case-Insensitive search for the word "Vi"
   
   if (preg_match("/\bVi\b/i", $line, $match)) :
      print "Match found!";
      endif;
?>

这将产生以下输出-

Match found!

PHP 中的 preg_match()函数 - 无涯教程网无涯教程网提供preg_match() - 语法 int preg_match ( string pattern , string string [, array pat...https://www.learnfk.com/php/php-preg-match.html

你可能感兴趣的:(无涯教程,php)