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
> 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 );
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
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
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/
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
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.
---
7 matches
Mail list logo