字符串搜索 php通过正则表达式进行字符串搜索的简单范例
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.";
}
?>
精彩图集
精彩文章






