开发者

Php array to formatted Text Key : Value

开发者 https://www.devze.com 2023-04-10 15:02 出处:网络
I have this array: Array ( [location] => Array ( [country] => India [coun开发者_运维技巧try_code] => IN [region] => [region_code] => [city] => [zip] => [latitude] => 13.044468

I have this array:

Array ( [location] => Array ( [country] => India [coun开发者_运维技巧try_code] => IN [region] => [region_code] => [city] => [zip] => [latitude] => 13.044468 [longitude] => 77.575665 [ip_address] => 123.236.219.154 [timestamp] => 1317496122 [route] => 3rd Cross Rd [neighborhood] => Basaveshwara Layout [sublocality] => BCITS PVT LTD [locality] => Bengaluru [administrative_area_level_2] => Bengaluru Rural [administrative_area_level_1] => Karnataka ) ) 

I wonder if there is a way that I can format it some what like this:

country: India
country_code:In

That is like Key : Value, Key : Value, Key : Value


Something like that?

foreach( $array as $key => $value ) {
  echo $key." : ".$value.",";
}

You have to check the last value and remove the "," then.

0

精彩评论

暂无评论...
验证码 换一张
取 消