如何使用PHP获取另一个数组内的数组的值

时间:2019-02-11 13:24:16

标签: php arrays multidimensional-array

如何使用php获取另一个数组内部的数组的值。 我试图获取地址所在的城市并写以下行 print_r($store_info[address[2]);,但一无所获

我的数组是

$store_info= Array ( [phone] => +918886330242 [address] => Array ( [street_1] => Plot no 19, Dr. Sundaraiah Colony, [street_2] => Picket, Secunderabad [city] => Hyderabad [zip] => 500003 [country] => IN [state] => TS ) [location] => [banner] => 8361 [icon] => 0 [gravatar] => 0 [show_more_ptab] => yes [store_ppp] => 10 [enable_tnc] => off [store_tnc] => [show_min_order_discount] => no [store_seo] => Array ( [dokan-seo-meta-title] => Online Grocery Store Hyderabad [dokan-seo-meta-desc] => Online Grocery Store in Hyderabad / Secunderabad is one of the best online grocery store for wholesale and retail [dokan-seo-meta-keywords] => [dokan-seo-og-title] => [dokan-seo-og-desc] => [dokan-seo-og-image] => 0 [dokan-seo-twitter-title] => [dokan-seo-twitter-desc] => [dokan-seo-twitter-image] => 0 ) [find_address] => [dokan_store_time] => Array ( [sunday] => Array ( [open] => close [opening_time] => [closing_time] => ) [monday] => Array ( [open] => close [opening_time] => [closing_time] => ) [tuesday] => Array ( [open] => close [opening_time] => [closing_time] => ) [wednesday] => Array ( [open] => close [opening_time] => [closing_time] => ) [thursday] => Array ( [open] => close [opening_time] => [closing_time] => ) [friday] => Array ( [open] => close [opening_time] => [closing_time] => ) [saturday] => Array ( [open] => close [opening_time] => [closing_time] => ) ) [dokan_store_time_enabled] => no [dokan_store_open_notice] => [dokan_store_close_notice] => [profile_completion] => Array ( [phone] => 10 [banner] => 15 [store_name] => 10 [address] => 10 [Bank] => 15 [next_todo] => Add Profile Picture to gain 15% progress [progress] => 60 [progress_vals] => Array ( [banner_val] => 15 [profile_picture_val] => 15 [store_name_val] => 10 [social_val] => Array ( [fb] => 2 [gplus] => 2 [twitter] => 2 [youtube] => 2 [linkedin] => 2 ) [payment_method_val] => 15 [phone_val] => 10 [address_val] => 10 [map_val] => 15 ) ) [setting_minimum_order_amount] => [setting_order_percentage] => [support_btn_name] => [show_support_btn] => yes )

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

您可以直接使用键,因为它们都是关联数组:

$city = $store_info['address']['city'];

var_dump($city);