I have an php array like this (var_dump) I need change one of it's element
  array (size=204)
          'Address' => 
            array (size=3)
              'City' => 
                array (size=3)
                  0 => string 'return $this->hasOne(City::className(), ['id' => 'cityId']);' 
                  1 => string 'City' (length=4)
                  2 => boolean false
              'CityDistrict' => 
                array (size=3)
                  0 => string 'return $this->hasOne(CityDistrict::className(), ['id' => 'cityDistrictId']);' (length=76)
                  1 => string 'CityDistrict' (length=12)
                  2 => boolean false
              'Contacts' => 
                array (size=3)
                  0 => string 'return $this->hasMany(Contact::className(), ['addressId' => 'id']);' 
                  1 => string 'Contact' (length=7)
                  2 => boolean true
          'City' => 
            array (size=3)
              'Addresses' => 
                array (size=3)
                  0 => string 'return $this->hasMany(Address::className(), ['cityId' => 'id']);' 
                  1 => string 'Address' (length=7)
                  2 => boolean true
              'Region' => 
                array (size=3)
                  0 => string 'return $this->hasOne(Region::className(), ['id' => 'regionId']);' (length=64)
                  1 => string 'Region' (length=6)
                  2 => boolean false
              'CityDistricts' => 
                array (size=3)
                  0 => string 'return $this->hasMany(CityDistrict::className(), ['cityId' => 'id']);' 
                  1 => string 'CityDistrict' (length=12)
                  2 => boolean true
          'CityDistrict' => 
            array (size=2)
              Addresses => 
                array (size=3)
                  0 => string 'return $this->hasMany(Address::className(), ['cityDistrictId' => 'id']);' 
                  1 => string 'Address' (length=7)
                  2 => boolean true
              'City' => 
                array (size=3)
                  0 => string 'return $this->hasOne(City::className(), ['id' => 'cityId']);'
                  1 => string 'City' (length=4)
                  2 => boolean false
How can i change value 'CityDistrict' in this loop? or 'Addresses'? using php foreach My code doesn't work please help understand what wrong!
  private static function checkExistClass($relations)
    {
        foreach ($relations as $name => $relation) {
            foreach ($relation as $functionName => $functionValue) {
                $functionNameGet = 'get' . $functionName;
                $directory = new Model;
                if (method_exists($directory, $functionNameGet)) {
                    $relation['funky_key_' . $functionName] = $functionValue;
                    unset($relation[$functionName]);
                }
            }
        }
        return $relations;
    }
 
     
     
     
    