<?php function show($var=null){
if(empty($var)) {
echo 'null';
}else if(is_array($var) || is_object($var)){
echo '<pre>';
print_r($var);
echo '</pre>';
}else{
echo $var;
}
}
$pattern='/[0-9]/';
$subject='asd78dfgfd1dfg2asdf8sadf6asdf9';
$m1=$m2=array();
$t1=preg_match($pattern,$subject,$m1);//返回匹配的次数,这个函数只匹配一次
$t2=preg_match_all($pattern,$subject,$m2);//返回匹配的次数,这个函数只匹配多次
show($m1);
echo '<hr/>';
show($m2);
echo '<hr/>';
show($t1.'||'.$t2);
来源:https://www.cnblogs.com/QMM2008/p/4567698.html