PHP:未识别索引:productOptionValue
该索引已存在。 不知道我做错了什么PHP:未识别索引:productOptionValue,php,arrays,multidimensional-array,Php,Arrays,Multidimensional Array,该索引已存在。 不知道我做错了什么 foreach($optionValue['productOptionValue'] as $value): // error here endforeach; 请帮忙 据我所知,您有一个属性为“optionValues”的对象。假设初始变量名为“$sexy”: 因此,以下几点应该可以做到: $sexy = Array ( [optionValues] => Array ( [34] => Array
foreach($optionValue['productOptionValue'] as $value): // error here
endforeach;
请帮忙 据我所知,您有一个属性为“optionValues”的对象。假设初始变量名为“$sexy”: 因此,以下几点应该可以做到:
$sexy = Array
(
[optionValues] => Array
(
[34] => Array
(
[id_product_option] => 1
[option_value] => Hello
[required] => 1
[productOptionValue] => Array
(
[0] => Array
(
[id_product_option_value] => 1
[id_option_value] => 88
[quantity] => 12
[subtract] => 1
[price] => 232.0000
[price_prefix] => r
[weight] => 23.00000000
[weight_prefix] => k
)
)
)
它应该是
$optionValue[34]['productOptionValue']
试试这个foreach($optionValue[34]['productOptionValue']作为$value){}
$sexy = Array
(
[optionValues] => Array
(
[34] => Array
(
[id_product_option] => 1
[option_value] => Hello
[required] => 1
[productOptionValue] => Array
(
[0] => Array
(
[id_product_option_value] => 1
[id_option_value] => 88
[quantity] => 12
[subtract] => 1
[price] => 232.0000
[price_prefix] => r
[weight] => 23.00000000
[weight_prefix] => k
)
)
)
foreach($sexy['optionValues'][34]['productOptionValue'] as $value):
// I should be nice now and not throw an error here
endforeach;