PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » PHP » PHP_Compat » Bug #4466

str_split() dont work with big split_lenght parameter

Details

Submitted2005-05-29 14:38 UTC
Fromp_m at email dot cz
Assignedaidan
StatusClosed
PackagePHP_Compat
PHP VersionIrrelevant
OSIrrelevant
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;
}
...