So I'm trying to return multiple fields from a JSON string using PHP but whenever I try to use foreach twice the second one doesn't display. The JSON data has some information which returns a varying numbers of fields and I want it to be able to return 1 or 10 if needed. The code I have so far works great for that, but when I go to return another foreach after it nothing shows up. If I add the fields I'm trying to include in the second foreach to the first then sometimes many extras are created based off the first fields returns being possibly 10.
Here's the PHP
foreach($decoded_results['sam_data']['registration']['qualifications']['acass']['answers'] as $acass)
{
echo '<strong>ACASS Answer Text: </strong>' . ($acass['answerText'] ? 'Yes' : 'No') .'</br>';
echo '<strong>ACASS Section: </strong>   '.$acass['section'].'</br>';
}
foreach($decoded_results ['sam_data']['registration']['qualifications']['acass']['answers']['FormerFirm'] as $formerfirm)
{
echo '<strong>Former Firm ID: </strong>   '.$formerFirm['id'].'</br>';
echo '<strong>Former Firm Year Established: </strong>   '.$formerFirm['yearEstablished'].'</br>';
}
Here's the JSON
"qualifications": {
"acass": {
"id": "SF330",
"answers": [
{},
{
"answerText": "Yes",
"section": "SF330.2"
},
{
"FormerFirm": {
"id": 1,
"yearEstablished": aaaaaaaaa,
"name": "aaaaaaaaaaa",
"duns": aaaaaaaaaa
},
The JSON structure goes qualifications / acass and then answertext and section are on the same level as former firm.
Any help you guys provide is greatly appreciated. Thank you for your time.