0
<?php function getCurrencyFor($arr, $findCountry) {
foreach($arr as $country) {
if ($country->name->common == $findCountry) {
$currency = $country->currency[0];
$capital = $country->capital;
$region = $country->region;
break;
}
}
return $country();
}
$json = file_get_contents("https://raw.githubusercontent.com/mledoze/countries/master/countries.json");
$arr = json_decode($json);
// Call our function to extract the currency for Angola:
$currency = getCurrencyFor($arr, "Aruba");
echo $country('$capital');
echo $country('$currency');
echo $country('$region');
?>
関連するオブジェクトを取得し、私はこの記事に続く - https://stackoverflow.com/a/38906191/3939981.JSONファイル - 値を検索し、
私は関数内のコードを書き換えた場合、それはたぶん、いくつかの部分
<?php function getCurrencyFor($arr, $findCountry) {
foreach($arr as $country) {
if ($country->name->common == $findCountry) {
$currency = $country->currency[0];
$capital = $country->capital;
$region = $country->region;
echo $capital;
echo $currency;
echo $region;
break;
}
}
return $currency;
}
$json = file_get_contents("https://raw.githubusercontent.com/mledoze/countries/master/countries.json");
$arr = json_decode($json);
// Call our function to extract the currency for Angola:
$currency = getCurrencyFor($arr, "Aruba");
?>
の作品すべてのコメントと考えて
私はもう一度手伝ってくれてうれしいです...これはうまくいきます... 100万ドルのおかげで、私は関数の名前を変更しました。 –
回答を受け入れたものとしてマークすることを忘れないでください。 – trincot
その素晴らしい...私は –