Home » PHP » PHP_Compat » Bug #4466
str_split() dont work with big split_lenght parameter
Details
| Submitted | 2005-05-29 14:38 UTC |
|---|---|
| From | p_m at email dot cz |
| Assigned | aidan |
| Status | Closed |
| Package | PHP_Compat |
| PHP Version | Irrelevant |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-05-29 14:38 UTC] p_m at email dot cz
Description:
------------
with big split_length par. (i try 500000) => Warning: preg_match_all() [function.preg-match-all]: Compilation failed: number too big in {} quantifier at offset 10 in ...
[2005-05-29 15:14 UTC] p_m at email dot cz
solution:
...
if ($split_length<1000) {
preg_match_all('/.{1,' . $split_length . '}/s', $string, $matches);
return $matches[0];
} else {
$arr=array ();
// *** //
$idx=0;
$pos=0;
$len=strlen($string);
// *** //
while ($len>0) {
$blk=($len<$split_length)?$len:$split_length;
// *** //
$arr[$idx++]=substr($string,$pos,$blk);
// *** //
$pos+=$blk;
$len-=$blk;
}
// *** //
return $arr;
}
...