当我想在foreach
循环后显示某个值时出现问题,它确实想要在$product_option_value_data
中取product_option_value
的值
感谢您的帮助。
foreach ($product_option_value as $products_option_value) {
$product_option_value_data[] = [
'products_option_value_id' => $products_option_value['products_option_value_id'],
'option_value_id' => $products_option_value['option_value_id'],
'name' => $products_option_value['name'],
'image' => $products_option_value['image'],
'quantity' => $products_option_value['quantity'],
'subtract' => $products_option_value['subtract'],
'price' => $products_option_value['price'],
'price_prefix' => $products_option_value['price_prefix'],
'weight' => $products_option_value['weight'],
'weight_prefix' => $products_option_value['weight_prefix']
];
}
结果
var_dump($product_option_value_data);
array (size=1)
0 =>
array (size=10)
'products_option_value_id' => string '91' (length=2)
'option_value_id' => string '180' (length=3)
'name' => string 'M' (length=1)
'image' => null
'quantity' => string '100' (length=3)
'subtract' => string '0' (length=1)
'price' => string '0.0000' (length=6)
'price_prefix' => string '+' (length=1)
'weight' => string '0.00' (length=4)
'weight_prefix' => string '+' (length=1)
第2步
$product_option_data[] = [
'products_option_id' => $product_option['products_option_id'],
'products_option_value' => $product_option_value_data,
'option_id' => $product_option['option_id'],
'name' => $product_option['name'],
'type' => $product_option['type'],
'value' => $product_option['value'],
'required' => $product_option['required']
];
结果
var_dump($product_option_data);
array (size=1)
0 =>
array (size=7)
'products_option_id' => string '106' (length=3)
'products_option_value' =>
array (size=1)
0 =>
array (size=10)
...
'option_id' => string '40' (length=2)
'name' => string 'Taille' (length=6)
'type' => string 'select' (length=6)
'value' => null
'required' => null
问题在这里
var_dump($product_option_data['products_option_value']);
Classes/Shop/ProductsAttributesShop.php:188:null