$products = Array ( [products] => Array ( [0] => 12,11,10 [1] => 16,15,14
[2] => 600,103,20 ) );
$info = implode(",",$_POST['product']);
$info1 = implode(",",$_POST['product_weight']);
$info2 = implode(",",$_POST['quantity']);
admin_orderrequest_add($params,$products,$obj);
foreach($products as $k=>$v)
{
echo $product_id = $v[0];
echo $product_weight_id = $v[1];
echo $product_quantity = $v[2];
$weight_info = admin_get_weight_info($product_weight_id,$obj);
}
现在第一次输出:
12,10,11
16,15,14
600,103,20
必需的输出:
第一次
12
16
600
第二次数组的所有第二个值
第三次数组的所有第三值
答案 0 :(得分:2)
答案 1 :(得分:2)
MH2K9发布的答案有效,如果要遍历它们,也可以使用以下代码
$products = [[12,11,10], [16,15,14], [600,103,20]];
if(!empty($products) && isset($products[0])){
$product_ids = $products[0];
$product_weight_ids = $products[1];
$product_quantities = $products[2];
foreach($product_ids as $key=>$v)
{
echo $product_id = $v; echo "<br/>";
echo $product_weight_id = $product_weight_ids[$key];echo "<br/>";
echo $product_quantity = $product_quantities[$key];echo "<br/>";
echo "<br/>";echo "<br/>";echo "<br/>";
$weight_info = admin_get_weight_info($product_weight_id,$obj);
}
}
输出:
12 16 600
11 15 103
10 14 20