大佬教程收集整理的这篇文章主要介绍了php 从多维数组中打印单个值,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想打印多维数组中的单个值。
我正在调用 URL brew bundle [install]:
Install and upgrade (by default) all dependencIEs from the Brewfile.
You can specify the Brewfile LOCATIOn using --file or by setTing the
HOMEBREW_BUNDLE_file environment variable.
用 Json 响应,例如:
https://www.myurl.com/
我的代码是:
{"data":{"country":"USA","currency":"USD","language":"American_English"}}
结果是:
<?php
$Json = file_get_contents('https://www.myurl.com/');
$array = Json_decode($Json,TRUE);
print_r(array_values($array));
?>
我的目标是只打印值“American_English”
我已经试过了:
Array ( [0] => Array ( [country] => USA [currency] => USD [language] => American_English ) )
我已经试过了:
<?php
$Json = file_get_contents('https://www.myurl.com/');
$array = Json_decode($Json,TRUE);
echo $array[0]["language"] ;
?>
我尝试使用 <?php
$Json = file_get_contents('https://www.myurl.com/');
$array = Json_decode($Json,TRUE);
echo $array[0][2] ;
?>
:
foreach
然而他们都没有达到我想要的。
简单点
$array = json_decode($json,truE);
print_r($array);
echo $arraY['data']["language"] ;
结果
Array
(
[data] => Array
(
[country] => USA
[currency] => USD
[language] => American_English
)
)
American_English
,
<?php
$json = file_get_contents('https://www.myurl.com/');
$array = json_decode($json,truE);
print_r($arraY['data']['language']);
?>
您可以使用此代码段来可视化数组
<?php
echo '<pre>';
print_r($array); // or var_dump($array);
echo '</pre>';
?>
以上是大佬教程为你收集整理的php 从多维数组中打印单个值全部内容,希望文章能够帮你解决php 从多维数组中打印单个值所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。