PHP的:获得数组值而不通过它迭代? [英] php: get array value without iterating through it?

查看:41
本文介绍了PHP的:获得数组值而不通过它迭代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我失去了理智.

print_r($ location); 列出一些地理数据.

array (
  'geoplugin_city' => 'My City',
  'geoplugin_region' => 'My Region',
  'geoplugin_areaCode' => '0',
  'geoplugin_dmaCode' => '0',
  'geoplugin_countryCode' => 'XY',
  'geopl ...

当我用foreach循环遍历它时,我可以打印每一行.但是,难道不能仅仅从数组中获取一个特定的值吗?

when I iterate through it with a foreach loop I can print each line. However shouldn't it be possible to just get a specific value out of the array?

like print $ location [g4]; 应该打印countryCode吗?谢谢!

like print $location[g4]; should print the countryCode shouldn't it? Thank you!

推荐答案

echo $location['geoplugin_countryCode'];

这篇关于PHP的:获得数组值而不通过它迭代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆