Question: I have this array:

```
$array = array(a, b, c, d, e, f, g);

```

I want to split it in two arrays depending if the index is even or odd, like this:

```
$odd = array(a, c, e, g);

$even = array(b, d, f);

```

Thanks in advance!

Answer: 
I am not sure if this is the most elegant way, but it should work a charm:

```
$odd=array();
$even=array();
$count=1;
foreach($array as $val)
{
    if($count%2==1)
    {
        $odd[]=$val;
    }
    else
    {
        $even[]=$val;
    }
    $count++;
}

```
```
    <?php

$array1 = array(0,1,2,3,4,5,6,7,8,9);
$oddarray = array();
$evenarray = array();

$count = 1;

echo "Original: ";
foreach ($array1 as $value)
 {
    echo "$value";
}

echo "<br> Even: ";

foreach ($array1 as $print) 
{
    if ($count%2==1) 
    {
        $evenarray = $print;
        echo "$print";
    }
    $count++;
}

echo "<br> Odd: ";

foreach ($array1 as $print2) {
    if ($count%2!=1) 
    {
        $oddarray[] = $print2;
        echo "$print2";
    }
    $count++;
}

?>

Output:

Original: 0123456789
Even: 02468
Odd: 13579

```