PHP code example of grmule / php-ziptastic

1. Go to this page and download the library: Download grmule/php-ziptastic 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/ */

    

grmule / php-ziptastic example snippets


$zt = new PHPZiptastic\Ziptastic(49504);

print $zt->city; // Grand Rapids

print $zt->lookup(34231)->city; // Sarasota

print $zt->lookup(44870); // Bloomingville, OH

print json_encode($zt); // {"city":"Bloomingville","state":"OH","zip":"44870"}

print $zt->lookup(12344)->city; // null
print $zt->error; // Invalid zip code

$zt = new Ziptastic(null, true);
$zt->lookup(12344); // exception thrown here

$zt = new Ziptastic(12344, true); // exception thrown here