2012-01-12 63 views
0

返回值,我用下面的PHP代码...阵列不是为给定的密钥

$settings[] = get_app_settings(); 
echo $settings['weight_unit']; 

但其投掷的错误“未定义指数”。

当我做print_r($settings);它生成以下...

Array ([0] => Array ([support_email] => [email protected] [support_phone] => 9812345678 [currency_symbol] => $ [weight_unit] => g. [catalogue_image_width] => 450 [catalogue_image_height] => 675 [single_product_image_width] => 500 [single_product_image_height] => 500 [product_image_width] => 200 [product_image_height] => 200 [tax_rate] => 1 [shipping_charges] => 0)) 

为什么没有返回的$settings['weight_unit'];值?

回答

2

其解决方法是从$settings中删除[](array)。不管怎么说,多谢拉。

1

尝试$settings = get_app_settings(); - 您可能想要直接指定返回的数组而不是指向$settings中的新数组元素。

+0

没错,那是我的错误,对不起。 – seoppc 2012-01-12 21:28:19