PHP code example of andylolz / everypolitician

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

    

andylolz / everypolitician example snippets

 php
use \EveryPolitician\EveryPolitician\EveryPolitician;
$ep = new EveryPolitician();

$australia = $ep->country('Australia');
$senate = $australia->legislature('Senate');
echo (string) $senate; // <Legislature: Senate in Australia>

$uk = $ep->country('UK');
$houseOfCommons = $uk->legislature('Commons');

$americanSamoa = $ep->country('American-Samoa');
$houseOfRepresentatives = $americanSamoa->legislature('House');

foreach ($ep->countries() as $country) {
    echo $country->name.' has '.count($country->legislatures()).'legislatures';
}
 php
$ep = EveryPolitician::fromUrl('https://cdn.rawgit.com/everypolitician/everypolitician-data/080cb46/countries.json');
 php
$ep = EveryPolitician::fromFilename('/home/andy/tmp/countries.json');