I'am trying to extract all the String value's from the key: ERRORS. This is my code so far and i have been able to 'un-nest' 2 layers but i cant seem to get any further then this. could someone show me how to access the value of the key: ERRORS.
I would like to store all the string values in an array
I have the following data structure.
var_export($results_decoded):
array (
0 => array ( 'Result' => array ( 0 => array ( 'ERRORS' => '99012: Weborder number already exists : 20211049', ), ), ),
1 => array ( 'Result' => array ( 0 => array ( 'ERRORS' => '99012: Weborder number already exists : 20211048', ), ), ),
2 => array ( 'Result' => array ( 0 => array ( 'ERRORS' => '99012: Weborder number already exists : 20211050', ), ), ),
3 => array ( 'Result' => array ( 0 => array ( 'ERRORS' => '99012: Weborder number already exists : 20211050', ), ), ),
4 => array ( 'Result' => array ( 0 => array ( 'ERRORS' => '99012: Weborder number already exists : 20211049', ), ), ),
5 => array ( 'Result' => array ( 0 => array ( 'ERRORS' => '99012: Weborder number already exists : 20211046', ), ), ),
6 => array ( 'Result' => array ( 0 => array ( 'ERRORS' => '99012: Weborder number already exists : 20211045', ), ), ),
7 => array ( 'result' => '2007: New Web Order created successfully', ),
8 => array ( 'Result' => array ( 0 => array ( 'ERRORS' => '99012: Weborder number already exists : 20211046', ), ), ),
a return() Statement:
[{"Result":[{"ERRORS":"99012: Weborder number already exists : 20211049"}]},{"Result":[{"ERRORS":"99012: Weborder number already exists : 20211048"}]},{"Result":[{"ERRORS":"99012: Weborder number already exists : 20211050"}]}]
a datadump of $results_array
array:2432 [▼
0 => array:1 [▼
"Result" => array:1 [▼
0 => array:1 [ …1]
]
]
1 => array:1 [▼
"Result" => array:1 [▼
0 => array:1 [ …1]
]
]
2 => array:1 [▼
"Result" => array:1 [▼
0 => array:1 [ …1]
]
]
3 => array:1 [▶]
4 => array:1 [▶]
5 => array:1 [▶]
6 => array:1 [▶]
7 => array:1 [▶]
8 => array:1 [▶]
9 => array:1 [▶]
My code:
$data = Log::all('RESPONSE');
$results_decoded = json_decode($data, true);
foreach ($results_decoded as $inner_array){
foreach ($inner_array as $value){
$result_array[] = $value;
}
}
return($result_array);
var_export()instead so the data is re-usable easily in an answer. Also we don't necessarily need all of it, just a relevant sample will do. You can edit the question to update it.var_export($results_decoded), is that correct?