要将 split 转换为 preg_split 由于 PHP 5.3 中的弃用,您可以:
$temp_array = split("'s*;'s*", $string);
$temp_array = preg_split("/'s*;'s*/", $string);
请注意preg_split所需的分隔符"/"。
$temp_array = split($needle, $string);
$temp_array = preg_split($needle, $string);
"$needle"也需要分隔符吗?
是的,如果要使用 preg_split
,$needle
必须是正则表达式。正则表达式需要分隔符。
如果不是需要拆分依据的正则表达式,请使用 explode()
。