Re: Re[2]: [PHP] split array in 2 halfs
| From: | Liz Fulghum | Date: | Wed, 31 Oct 2001 21:50:41 +0000 |
| Subject: | Re: Re[2]: [PHP] split array in 2 halfs | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73079@lists.php.net to get a copy of this message | ||
You could also grab the midpoint of the array:
$count = round(count($array), 0);
then populate your new arrays by using a foreach loop:
$x = 0;
foreach($array as $key => $value) {
if ($x <=$count) {
$array1[] = $value;
} else {
$array2[] = $value;
}
$x++;
}
"Daniel Harik" <gatop@hot.ee> wrote in message
news:11752292412.20011031232555@hot.ee...
> Want to split it in half
>
> 1 Big array:
>
> 1
> 2
> 3
> 4
> 5
> 6
>
> Want to make
>
>
> 1 Small array:
>
> 1
> 2
> 3
>
> 2 Small array:
> 4
> 5
> 6
>
> Thank You
>