我试图将数组推入其他数组,但它不起作用。此外,我已经尝试了array_push和不工作
foreach($cartitemCollection as $cartitem){
foreach($cartitem['product'] as $product){
$variablePrices = $variablePricesRepository->findByProductId($product['id']);
$product['var_price'] = $variablePrices; //not working
array_push( $product,$variablePrices ); //also not working
}
}
下一个迭代产品将被覆盖。但是你可以使用参考资料。
foreach($cartitemCollection as $cartitem){
foreach($cartitem['product'] as &$product){
$variablePrices = $variablePricesRepository->findByProductId($product['id']);
$product['var_price'] = $variablePrices;
}
}