Answer the question
In order to leave comments, you need to log in
How to output data from json sorting output by only one field?
So, there is a json file, something like this:
{
"games": [
{
"name": "FlatOut 2",
"image": "http:\/\/www.game-ost.ru\/static\/covers_soundtracks\/1\/1\/11195_599433.jpg",
"game_key": "DNVI5-74JHP-OLOQ2",
"start": 1441052980,
"winner": "https:\/\/vk.com\/id164746581"
},
{
"name": "Anachronox",
"image": "http:\/\/www.abcgames.sk\/udaje\/cd_obaly\/2\/230_f1.jpg",
"game_key": "GPXFT-J9GJ4-PF58L",
"start": 1441114401
},
{
"name": "Daikatana",
"image": "http:\/\/files.khinsider.com\/vgwallpaper\/1280x1024\/685-daikatana-005-wywlf.jpg",
"game_key": "GPXFT-J9GJ4-PF58L"
}
]
}
Answer the question
In order to leave comments, you need to log in
https://dev.mysql.com/doc/refman/5.7/en/view-restr...
Before MySQL 5.7.7, subqueries cannot be used in the FROM clause of a view.
because views cannot have a subquery in the FROM part of the
emnip, in recent versions there is no such restriction
$json = '{
"games": [
{
"name": "FlatOut 2",
"image": "http:\/\/www.game-ost.ru\/static\/covers_soundtracks\/1\/1\/11195_599433.jpg",
"game_key": "DNVI5-74JHP-OLOQ2",
"start": 1441052980,
"winner": "https:\/\/vk.com\/id164746581"
},
{
"name": "Anachronox",
"image": "http:\/\/www.abcgames.sk\/udaje\/cd_obaly\/2\/230_f1.jpg",
"game_key": "GPXFT-J9GJ4-PF58L",
"start": 1441114401
},
{
"name": "Daikatana",
"image": "http:\/\/files.khinsider.com\/vgwallpaper\/1280x1024\/685-daikatana-005-wywlf.jpg",
"game_key": "GPXFT-J9GJ4-PF58L"
}
]
}';
$data = json_decode($json, true);
foreach ($data['games'] as $game)
{
if (isset($game['winner']))
{
//выводим
print $game['name'] . "<br>";
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question