Home  >  Article  >  Backend Development  >  重写PHP的explode方法

重写PHP的explode方法

WBOY
WBOYOriginal
2016-06-23 13:47:53877browse

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);}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn