public function getIsoAlpha2FromName($name)
    {
        // First try and fetch from alpha3 code.
        try {
            return $this->iso->alpha3($this->getCodeFromCountry($name))['alpha2'];
        } catch (OutOfBoundsException $e) {
            // Nothing code continues.
        }

        // Couldn't getch alpha3 from code try from country name.
        try {
            return $this->iso->name($name)['alpha2'];
        } catch (OutOfBoundsException $e) {
            $this->logger->warning("Can't get valid alpha2 code for country '$name'");
        }

        return "OT";
    }
public function getIsoAlpha2FromName($name)
    {
        // First try and fetch from alpha3 code.
        try {
            return $this->iso->alpha3($this->getCodeFromCountry($name))['alpha2'];
        } catch (OutOfBoundsException $e) {
            // Nothing code continues.
        }

        // Couldn't getch alpha3 from code try from country name.
        try {
            return $this->iso->name($name)['alpha2'];
        } catch (OutOfBoundsException $e) {
            $this->logger->warning("Can't get valid alpha2 code for country '$name'");
        }

        return "OT";
    }
public function getIsoAlpha2FromName ( $ name ) { // First try and fetch from alpha3 code. try { return $ this -> iso -> alpha3 ( $ this -> getCodeFromCountry ( $ name ) ) [ 'alpha2' ] ; } catch ( OutOfBoundsException $ e ) { // Nothing code continues. } // Couldn't getch alpha3 from code try from country name. try { return $ this -> iso -> name ( $ name ) [ 'alpha2' ] ; } catch ( OutOfBoundsException $ e ) { $ this -> logger -> warning ( "Can't get valid alpha2 code for country '$name'" ) ; } return "OT" ; }
Get iso2 code from Maniaplanet Country name

@param $name

@return string
Get iso2 code from Maniaplanet Country name