如:$str="php如何將字 符串中322的字母數字sf f45d和中文_分割?";按數字或字母分割。php
$str = "php如何將字 符串中322的字母數字Asf f45d和中文_分割?"; $arr = preg_split("/([a-zA-Z0-9]+)/", $str, 0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); print_r($arr);
結果spa
$new = array(); $new[0]="php"; $new[1]="如何將字 符串中"; $new[2]="322"; $new[3]="的字母數字"; $new[4]="sf"; $new[5]=" "; $new[6]="f45d"; $new[7]="和中文_分割?";