<?php
$mas = array ('a' => 4,
'b' => 8,
'c' => 1,
'd' => 3,
'e' => 9,
'f' => 10
);
$mas = array (1,7,9,2,6,1,9);
$step = 0;
foreach ($mas as $k => $v)
{
if(($step % 2) === 0)
{
$res[0][$k] = $v;
}
else
{
$res[1][$k] = $v;
}
$step++;
}
echo "<pre>";
print_r($mas);
echo "</pre>";
echo "<pre>";
print_r($res);
echo "</pre>";
$steps = count($mas)+1;
$what_mas = 1;
for($i=0; $i < $steps; $i++)
{
foreach ($res[$what_mas] as $key => $val)
{
$total_result[$key] = $val;
unset($res[$what_mas][$key]);
break;
}
$what_mas = !$what_mas;
}
echo "<pre>";
print_r($total_result);
echo "</pre>";
?>
Комментариев нет:
Отправить комментарий