Re: splitting string into array
| From: | Matt M. | Date: | Wed, 29 Sep 2004 14:17:53 +0000 |
| Subject: | Re: splitting string into array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198192@lists.php.net to get a copy of this message | ||
> Example,
> A12B05C45D34
>
> I need to split this into chunks of three A12,B05,C45..etc?
not sure if your string will always be the same patter but this might work
$string = 'A12B05C45D34';
$array = preg_split ( '/([a-zA-Z]\d{2})/', $string,
-1,PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
print_r($array);