public static function nationality_form(PDO $db, $nationalityId = -1) { $country_manager = new CountryManager($db); $countries = $country_manager->getCountries(); foreach ($countries as $country) { if ($country->id() == $nationalityId) { echo '<option countryid=' . $country->id() . '" value="' . $country->id() . '" selected="' . $nationalityId . '">' . $country->name() . '</option>'; } echo '<option countryid=' . $country->id() . '" value="' . $country->id() . '">' . $country->name() . '</option>'; } }
/** * Public function that creates a single instance */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
public function getCountryNames() { return $this->countryManager->getNames($this->alpha2); }
} } public function __construct($PersonID) { $this->NatIDNumber = $PersonID; $this->CountryCode = "ITA"; } } $IDs = array("90022815265", "MRTMTT25D09F205Z", "LolDupa"); $IDgroup = array(); class CountryManager { static function checkCountry($NatIDNumber) { if (strlen($NatIDNumber) == 11) { return new ID_POL($NatIDNumber); } elseif (strlen($NatIDNumber) == 16) { return new ID_ITA($NatIDNumber); } return null; } } foreach ($IDs as $ID) { array_push($IDgroup, CountryManager::checkCountry($ID)); } foreach ($IDgroup as $ID) { if ($ID != null) { echo $ID->retCountry() . "\n"; } } //echo "\nJeszcze dziala!";