2012-01-12 62 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