Answer the question
In order to leave comments, you need to log in
How to parse and find the desired value in Json?
I get this line from the server
[
{
"id": 963343,
"name": "\u0424\u043e\u0440\u043c\u0430 \u0433\u043e\u043b\u043e\u0441\u0430",
"name_eng": "Koe no katachi",
"year": "2016"
},
{
"id": 977743,
"name": "\u0424\u043e\u0440\u043c\u0430 \u0432\u043e\u0434\u044b",
"name_eng": "The Shape of Water",
"year": "2017"
},
{
"id": 493390,
"name": "\u0413\u043e\u043b\u043e\u0441\u0430",
"name_eng": "The Voices",
"year": "2014"
}
]
Answer the question
In order to leave comments, you need to log in
$json = '[
{
"id": 963343,
"name": "\u0424\u043e\u0440\u043c\u0430 \u0433\u043e\u043b\u043e\u0441\u0430",
"name_eng": "Koe no katachi",
"year": "2016"
},
{
"id": 977743,
"name": "\u0424\u043e\u0440\u043c\u0430 \u0432\u043e\u0434\u044b",
"name_eng": "The Shape of Water",
"year": "2017"
},
{
"id": 493390,
"name": "\u0413\u043e\u043b\u043e\u0441\u0430",
"name_eng": "The Voices",
"year": "2014"
}
]';
$array = json_decode($json, true);
$result = array_filter($array, function($item){
if ($item['name'] == 'Форма голоса' && $item['year'] == '2016') return $item;
});
var_dump($result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question