我有一个关联数组:
Array (
[0] => Array ( [term_title] => black )
[1] => Array ( [color_quantity] => 2 )
[2] => Array ( [color_price] => 22 )
[3] => Array ( [term_title] => blue )
[4] => Array ( [color_quantity] => 3 )
[5] => Array ( [color_price] => 33 ))
我怎样才能把它改成:
Array (
[0] => Array ( [term_title] => black, [color_quantity] => 2, [color_price] => 22 )
[1] => Array ( [term_title] => blue, [color_quantity] => 3, [color_price] => 33 ) )
我尝试以下代码:
$post = array();
for($i = 0; $i < 2; $i++){
foreach($feild_data as $data){
$post[$i][$data['name']] = $data['value'];
}
}
但它重复最后一个索引两次。IE
Array (
[0] => Array ( [term_title] => blue, [color_quantity] => 3, [color_price] => 33 )
[1] => Array ( [term_title] => blue, [color_quantity] => 3, [color_price] => 33 ) )
慕桂英4014372
陪伴而非守候