I have the following as part of a JSON array
"appendix": {
  "airlines": [
   {
    "fs": "AA",
    "iata": "AA",
    "icao": "AAL",
    "name": "American Airlines",
    "phoneNumber": "08457-567-567",
    "active": true
   },
   {
    "fs": "LY",
    "iata": "LY",
    "icao": "ELY",
    "name": "El Al",
    "phoneNumber": "+ 972-3-9771111",
    "active": true
   }
And I want to get the only the "name" of in the string that has an "iata" of "AA" (i.e. "American Airlines"). I tried writing a for loop where
$iata = "AA"
$appendix_airlines = $array["airlines"][0];
$app_airlines_length = count($appendix_airlines);      
        for ($i = 0; $i <= $app_airlines_length; $i ++) {
                if ($appendix_airlines[$i]["iata"] == "AA") {
                    echo $appendix_airlines[$i]["name"];
                };
        }
However, this just returns an undefined offset = 0, undefined offset = 1 etc error. How do I fix this?
Essentially, I want it to go and get the name of the airline based on the IATA code that got inputted.
 
     
     
    