我的购物车中有两件商品。我想以数组的形式显示ID,我试过但结果是:
Array ( [0] => Array ( [idp] => 11 ) [1] => Array ( [idp] => 9 ) )
我想要结果:
array(11,9)
我的控制员:
foreach($this->cart->contents() as $items):
$data_product_stock[] = array(
'idp' => $items['id'],
);
endforeach;
print_r($data_product_stock);
答案 0 :(得分:0)
你可以像这样创建数组
foreach($this->cart->contents() as $items):
$data_product_stock[] = $items['id'];
endforeach;
print_r($data_product_stock);
答案 1 :(得分:0)
试试这个
array_column($data_product_stock, 'idp');
它会给出ids
数组,但请记住$data_product_stock
应为数组