热搜:NVER node 开发 php

重写PHP的explode方法

2024-08-20 13:50:01
重写PHP的explode方法

function rexplode($delimiter, $str){	$d_len = strlen($delimiter);	$arr = array();	$i = $pos = 0;	while (false !== ($pos = stripos($str.$delimiter, $delimiter, $pos)) ) {		$arr[] = mb_substr($str, $i, $pos-$i);		$i = $pos + $d_len;		$pos += $d_len;	}	return array_filter($arr);}