Re: [PHP] splitting string into array

2004-09-29 Thread blackwater dev
Thanks all! On Wed, 29 Sep 2004 14:55:58 +0100, Chris Dowell <[EMAIL PROTECTED]> wrote: > In PHP4 > > $array = explode(';', chunk_split("A12B05C45D34", 3, ';')); > > In PHP4 > > $array = str_split("A12B05C45D34", 3); > > RTFM > > Cheers > > Chris > > > > blackwater dev wrote: > > > How

Re: [PHP] splitting string into array

2004-09-29 Thread Matt M.
> 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 );

Re: [PHP] splitting string into array

2004-09-29 Thread Gareth Williams
Try something like this: $string = 'A12B05C45D34'; $string = chunk_split($string, 3, ':'); //Should give you 'A12:B05:C45:D34'; $array = explode(":",$string); Cheers, Gareth On 29 Sep 2004, at 15:40, blackwater dev wrote: How can I take a string and create an array? Example, A12B05C45D34 I need to

Re: [PHP] splitting string into array

2004-09-29 Thread Martin Holm
blackwater dev wrote: How can I take a string and create an array? Example, A12B05C45D34 I need to split this into chunks of three A12,B05,C45..etc? Thanks! | use str_split() if you dont have php5, you can use the following code: | if (!function_exists('str_split')) { function str_split ($s

Re: [PHP] splitting string into array

2004-09-29 Thread Marek Kilimajer
blackwater dev wrote: How can I take a string and create an array? Example, A12B05C45D34 I need to split this into chunks of three A12,B05,C45..etc? Thanks! $chunks = preg_split('/(.{3})/', $str, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); -- PHP General Mailing List (http://www.php.net/

Re: [PHP] splitting string into array

2004-09-29 Thread Chris Dowell
In PHP4 $array = explode(';', chunk_split("A12B05C45D34", 3, ';')); In PHP4 $array = str_split("A12B05C45D34", 3); RTFM Cheers Chris blackwater dev wrote: How can I take a string and create an array? Example, A12B05C45D34 I need to split this into chunks of three A12,B05,C45..etc? Thanks! -- PHP Ge

Re: [PHP] splitting string into array

2004-09-29 Thread raditha dissanayake
blackwater dev wrote: How can I take a string and create an array? Example, A12B05C45D34 I need to split this into chunks of three A12,B05,C45..etc? split() chunk_split() substr() preg_split() Thanks! -- Raditha Dissanayake. ---