<?php /** * Created by PhpStorm. * User: Ollydebug * Date: 2015/11/13 * Time: 22:55 */ //阉割版preg_filter //preg_grep函数只会去做匹配的操作,不做替换 $pattern = '/[0-9]/'; $subject = array('weuy','r3ui','76as83','s','0ck9'); $arr = preg_grep($pattern,$subject); show($arr); function show($var){ if(empty($var)){ echo 'null'; }elseif(is_array($var)||is_object($var)){ // array,object echo '<pre class="brush:php;toolbar:false">'; print_r($var); echo ''; }else{ //string,int,float echo $var; } } ?>
以上就是(PHP)正規表示式-preg_grep函數用法的內容,更多相關內容請關注PHP中文網(m.sbmmt.com)!