龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

字符串搜索 php通过正则表达式进行字符串搜索的简单范例

时间:2014-05-31 15:31来源:网络整理 作者:网络 点击:
分享到:
php通过正则表达式进行字符串搜索的简单范例 [代码片段(12行)]
<?php
$string_to_search = "w3mentor.com";
$regex = "/tor/";
$num_matches = preg_match($regex, $string_to_search);

if ($num_matches > 0) {
  echo "Found a match!";
} else {
  echo "No match. Sorry.";
}
?>

精彩图集

赞助商链接