PHP Classes

File: StatesInfoTestCH.php

Recommend this page to a friend!
  Classes of Stefan Kientzler   PHP Holidays Library for Germany, Austria and Switzerland   StatesInfoTestCH.php   Download  
File: StatesInfoTestCH.php
Role: Example script
Content type: text/plain
Description: Testscript for Switzerland
Class: PHP Holidays Library for Germany, Austria and Switzerland
Get the holiday dates of specific countries
Author: By
Last change:
Date: 4 years ago
Size: 1,012 bytes
 

Contents

Class file image Download
<?php
use lib\StatesInfo\StatesInfo;

require_once
'lib/StatesInfo/StatesInfo.php';

   
$oSI = new StatesInfo('CH');
   
   
$aStates = $oSI->listStates();
    echo
'<h1>Liste der Kantone mit Feiertagen 2020</h1>' . PHP_EOL;
    echo
'<ul>' . PHP_EOL;
    foreach (
$aStates as $strShort => $strState) {
        echo
'<li>' . $strState . ' (' . $strShort . ')</li>' . PHP_EOL;
       
$aList = $oSI->listOfficialHolidays($strShort, 2020);
        echo
'<ul>' . PHP_EOL;
        foreach (
$aList as $id => $aHoliday) {
            echo
'<li>' . date('d.m.Y', $aHoliday['date']) . ': ' . $aHoliday['name'] . '</li>' . PHP_EOL;
        }
        echo
'</ul>' . PHP_EOL;
    }
    echo
'</ul>' . PHP_EOL;

    echo
'<h1>Kanton f&uuml;r Postleitzahl 8212</h1>' . PHP_EOL;
    echo
$oSI->getStateFromPostcode(8212) . PHP_EOL;

    echo
'<h1>Feiertage 2021 in Graub&uuml;nden</h1>' . PHP_EOL;
   
$aList = $oSI->listOfficialHolidays('GR', 2021);
    foreach (
$aList as $aHoliday) {
        echo
date('d.m.Y', $aHoliday['date']) . ': ' . $aHoliday['name'] . '<br/>' . PHP_EOL;
    }