日期:2014-05-17 浏览次数:20519 次
Array
(
[0] => 123
[1] => 456
[2] => 789
)
$url = array('123','456','789');
能将上面这个数组,组装成下面的这个吗?
$urls = array(array('url'=>'123'),array('url'=>'456'),array('url'=>'789'));
Array
(
[0] => Array
(
[url] => 123
)
[1] => Array
(
[url] => 456
)
[2] => Array
(
[url] => 789
)
)
foreach ($url as $url_value) {
$urls[] = array('url'=>$url_value);
}
$ar = array(123, 456, 789);Array
$t = array_map('array_combine',array_chunk(array_fill(0,count($ar), 'url'), 1), array_chunk($ar, 1));
print_r($t);