Home >Backend Development >PHP Tutorial >PHP+regular splits alphanumeric and Chinese characters in a string
For example: $str="How does php split the 322 alphanumeric characters sf f45d and Chinese_ in the string?"; Split by numbers or letters.
$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);
Result
$new = array(); $new[0]="php"; $new[1]="如何将字 符串中"; $new[2]="322"; $new[3]="的字母数字"; $new[4]="sf"; $new[5]=" "; $new[6]="f45d"; $new[7]="和中文_分割?";
For more php+regular separation of alphanumeric and Chinese characters in a string, please pay attention to the PHP Chinese website!