i have a JSON that i decode into array:
$json = '[{"CODICE":"A","COD. CRISI":1},{"CODICE":"25","COD. CRISI":1}]';
$arraydati = json_decode($json);
If i do print_r($arraydati);
, i have this array:
Array
(
[0] => stdClass Object
(
[CODICE] => A
[COD. CRISI] => 1
)
[1] => stdClass Object
(
[CODICE] => 25
[COD. CRISI] => 1
)
)
Now i want iterate the array and if "Codice" contains 25 i read the value.
I have a foreach loop
foreach($arraydati as $key=>$value){
if($key['CODICE'] === '1'){
echo($value['COD. CRISI']);
}
}
but non print nothing, where is the problem?