JSONファイルの特定のエントリを選択するにはどうすればよいですか?多次元json php
{
"status" : "success",
"data" : {
"items" : [
{
"market_hash_name" : "AK-47 | Redline (Field-Tested)",
"total_items" : 923,
"lowest_price" : "4.00",
"highest_price" : "300.00",
"cumulative_price" : "8722.77",
"recent_sales_info" : {
"hours" : "18.07",
"average_price" : "4.21"
}
},
{
"market_hash_name" : "AK-47 | Redline (Minimal Wear)",
"total_items" : 51,
"lowest_price" : "14.26",
"highest_price" : "100.00",
"cumulative_price" : "1089.71",
"recent_sales_info" : {
"hours" : "23.37",
"average_price" : "14.36"
}
}
]
}
}
スクリーンショット:
私のPHPスクリプト:
$steam = "AK-47 | Redline (Field-Tested)";
$link = 'list.json';
$string = file_get_contents($link);
$obj = json_decode($string);
if($obj->{'status'} == "success") die("notfound");
$lowest_price = $obj->{'lowest_price'};
$lowest_price[strlen($lowest_price)] = 0;
echo $lowest_price;
がどのように私は例えば "TOTAL_ITEMS" とAK-の "平均価格" を選択することができます47レッドライン(実地試験済み)? market_hash_nameは変数に保存され、関連する値を他の変数に保存します。
ありがとうございます。 よろしく。 Enge
'json_decode($ strの、真の)'あなたに配列 –