It could be:
function split2($string, $needle, $nth) {
$max = strlen($string);
$n = 0;
for ($i=0; $i<$max; $i++) {
if ($string[$i] == $needle) {
$n++;
if ($n >= $nth) {
break;
}
}
}
$arr[] = substr($string, 0, $i);
$arr[] = substr($string, $i+1, $max);
return $arr;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…