我在下面有一个数组链接 -
Array
(
[0] => Array
(
[0] => Image One
[1] => Image Two
[2] => Image Three
)
[1] => Array
(
[0] => Title One
[1] => Title Two
[2] => Title Three
)
[2] => Array
(
[0] => Description One
[1] => Description Two
[2] => Description Three
)
)
但我想在下面这样做。
Array
(
[0] => Image One
[1] => Title One
[2] => Description One
)
Array
(
[0] => Image Two
[1] => Title Two
[2] => Description Two
)
Array
(
[0] => Image Three
[1] => Title Three
[2] => Description Three
)
有人可以帮助我,我该怎么做。
答案 0 :(得分:0)
试试这个,你会在阵列中按顺序排序:
{{1}}
答案 1 :(得分:0)
foreach ($array as $key => $val)
{
${"array_".($key+1)} = $val;
print_r(${"array_".($key+1)});
}
答案 2 :(得分:-1)
假设$result
是一个多维数组
$temp1 = array();
$temp2 = array();
$temp3 = array();
foreach($result as $k=>$v){
if($k == 0){
$temp1 = array(
0 => $result[0][$k],
1 => $result[1][$k],
2 => $result[2][$k]
);
}else if($k == 1){
$temp2 = array(
0 => $result[0][$k],
1 => $result[1][$k],
2 => $result[2][$k]
);
}else{
$temp3 = array(
0 => $result[0][$k],
1 => $result[1][$k],
2 => $result[2][$k]
);
}
}
echo "<pre>";print_R($temp1);echo "</pre>";
echo "<pre>";print_R($temp2);echo "</pre>";
echo "<pre>";print_R($temp3);echo "</pre>";