copy code code below:
/**
* Detailed explanation of PHP implementation of explore() function
*/
$str = ',1,2,3,4,321321,aaa,bbb';
function myExplode($seg,$str,$limit=0){
$_ret = array(0=>'') ;
$len = strlen($str);
$slen = strlen($seg);
$_limit = 0;
for($i=0; $i<$len; $ i++){
if(substr($str,$i,$slen) == $seg ){
$_limit++;
$i += $slen-1;
continue;
}else{
$_ret[$_limit] .= $str[$i];
}
}
if($limit < 0 )
$_ret = array_slice($_ret, 0 , $limit );
else{
$_ret = $limit > ;= count($_right) ? $_ret : array_merge(array_slice($_ret, 0 , $limit-1 ), array(implode( $seg , array_slice($_ret,$limit-1))));
}
return $_ret;
}
var_dump(myExplode("4",$str));
echo "
";
var_dump(explode("4",$str));
echo "
";
?>
手机limit的二者。。电影符的电影
http://www.bkjia.com/PHPjc/327728.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327728.htmlTechArticle copy code code below: ?php /*** Detailed explanation of PHP's implementation of explore() function*/ $str = ',1,2, 3,4,321321,yyyy,yyyy'; function myExplode($seg,$str,$limit=0){ $_ret = array(0=''); $len = s...