<?php
$json = '{
"result":{
"Plaintiff":{
"2015":{
"SolutionsPerv":{
"To leave the decision (determination) of the court of first instance and the ruling of the court of appeal unchanged, and the cassation appeal - unsatisfied":{
"Amount":0,
"Quantity":1
}
},
"DecisionsApp":{
"To leave the decision (determination) of the court of first instance and the ruling of the court of appeal unchanged, and the cassation appeal - unsatisfied":{
"Amount":0,
"Quantity":1
}
},
"ResheniyaKass":{
"To leave the decision (determination) of the court of first instance and the ruling of the court of appeal unchanged, and the cassation appeal - unsatisfied":{
"Amount":0,
"Quantity":1
}
},
"ResheniyaNadz":[
]
}
},
"Respondent":{
"2018":{
"SolutionsPerv":{
"Leave the ruling of the court of first instance and the ruling of the court of appeal unchanged, the cassation appeal without satisfaction":{
"Amount":24000,
"Quantity":1
}
},
"ResheniyaKass":{
"Leave the ruling of the court of first instance and the ruling of the court of appeal unchanged, the cassation appeal without satisfaction":{
"Amount":24000,
"Quantity":1
}
},
"ResheniyaNadz":[
]
},
"2019":{
"ResheniyaKass":{
"To leave the decision (determination) of the court of first instance and the ruling of the court of appeal unchanged, and the cassation appeal - unsatisfied":{
"Amount":0,
"Quantity":1
}
},
"ResheniyaNadz":[
]
},
"2020":{
"SolutionsPerv":{
"There is no decision":{
"Amount":0,
"Quantity":2
}
},
"DecisionsApp":[
]
}
},
"Third Person":{
"2015":{
"SolutionsPerv":{
"To leave unchanged the decision and (or) the decision of the appellate instance, and the cassation appeal - without satisfaction (clause 1 of part 1 of article 287 of the APC)":{
"Amount":0,
"Quantity":1
}
},
"ResheniyaNadz":[
]
}
}
}
}';
$debug = true;
$arr = json_decode($json, true);
$result = getArray($arr, 'Respondent'); // use e.g. Plaintiff or Respondent as $id
print_r($result);
function getArray(array $arr = [], string $id = '', &$store = []): array
{
foreach ($arr as $key => $value) {
if ($key === $id && is_array($value)) { // identifier found
return $store = $value; // store result array
} elseif (is_array($value)) getArray($value, $id, $store); // keep digging
}
return $store;
}
Array
(
[2018] => Array
(
[SolutionsPerv] => Array
(
[Leave the ruling of the court of first instance and the ruling of the court of appeal unchanged, the cassation appeal without satisfaction] => Array
(
[Amount] => 24000
[Quantity] => 1
)
)
[ResheniyaKass] => Array
(
[Leave the ruling of the court of first instance and the ruling of the court of appeal unchanged, the cassation appeal without satisfaction] => Array
(
[Amount] => 24000
[Quantity] => 1
)
)
[ResheniyaNadz] => Array
(
)
)
[2019] => Array
(
[ResheniyaKass] => Array
(
[To leave the decision (determination) of the court of first instance and the ruling of the court of appeal unchanged, and the cassation appeal - unsatisfied] => Array
(
[Amount] => 0
[Quantity] => 1
)
)
[ResheniyaNadz] => Array
(
)
)
[2020] => Array
(
[SolutionsPerv] => Array
(
[There is no decision] => Array
(
[Amount] => 0
[Quantity] => 2
)
)
[DecisionsApp] => Array
(
)
)
)
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Array
(
[2018] => Array
(
[SolutionsPerv] => Array
(
[Leave the ruling of the court of first instance and the ruling of the court of appeal unchanged, the cassation appeal without satisfaction] => Array
(
[Amount] => 24000
[Quantity] => 1
)
)
[ResheniyaKass] => Array
(
[Leave the ruling of the court of first instance and the ruling of the court of appeal unchanged, the cassation appeal without satisfaction] => Array
(
[Amount] => 24000
[Quantity] => 1
)
)
[ResheniyaNadz] => Array
(
)
)
[2019] => Array
(
[ResheniyaKass] => Array
(
[To leave the decision (determination) of the court of first instance and the ruling of the court of appeal unchanged, and the cassation appeal - unsatisfied] => Array
(
[Amount] => 0
[Quantity] => 1
)
)
[ResheniyaNadz] => Array
(
)
)
[2020] => Array
(
[SolutionsPerv] => Array
(
[There is no decision] => Array
(
[Amount] => 0
[Quantity] => 2
)
)
[DecisionsApp] => Array
(
)
)
)