1. Go to this page and download the library: Download simp/php-toolkit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
simp / php-toolkit example snippets
$name = new Str("Chance Nyasulu");
$price = new Num(1234.5);
$list = new Arr([3, 1, 2]);
$phone = new Phone("0987678987", "MW");
$email = new Email("[email protected]");
$country = new Country("MW");
$data = new Arr(['address' => ['city' => 'Lilongwe']]);
$data->get('address.city'); // "Lilongwe"
$data->set('address.zip', '10101'); // new Arr with the value added
$data->has('address.city'); // true
$mw = new Country("MW"); // or Country::create("Malawi") / Country::create("MWI")
$mw->getName(); // "Malawi"
$mw->getAlpha2(); // "MW"
$mw->getAlpha3(); // "MWI"
$mw->getDialCode(); // "265"
$mw->getDialCodeFormatted(); // "+265"
$mw->getTld(); // ".mw"
$mw->getFlagUrl(); // flag image URL
$mw->getTimezone(); // "+02:00"
Country::all(); // array of all 249 Country objects
Country::search('mala'); // array of Country objects matching "mala"
Country::random(); // random Country
Country::fromDialCode('+44'); // Country("GB")
Country::tryFind('Narnia'); // null instead of throwing
$phone = new Phone("0987678987", "MW"); // national number + ISO country
$phone = Phone::create("+265987678987"); // or a full international number — country auto-detected
$phone->toE164(); // "+265987678987"
$phone->toInternational(); // "+265 987 678 987"
$phone->toNational(); // "0987 678 987"
$phone->getCountry(); // Country("MW")
$phone->getDialCode(); // "265"
$phone->getNationalNumber(); // "987678987"
$phone->isValid(); // true (plausible digit count)
$phone->equals($otherPhone);
Phone::isValidNumber("0987678987", "MW"); // true, no exception
Phone::tryParse("garbage"); // null instead of throwing