Home >Backend Development >PHP Tutorial >(PHP) Regular expression-Usage of preg_split function
<?php /** * Created by PhpStorm. * User: Ollydebug * Date: 2015/11/15 * Time: 10:13 */ //preg_split-升级版explode函数 //preg_split的主要意思是通过一个正则表达式分割字符串 $pattern = '/[0-9]/'; $subject = '钻3石2星5尘4拳'; $arr = preg_split($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; } } ?>
The above is the usage of (PHP) regular expression-preg_split function. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!