PHP code example of utrodus / malaysia-public-holiday
1. Go to this page and download the library: Download utrodus/malaysia-public-holiday 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/ */
utrodus / malaysia-public-holiday example snippets
use MalaysiaHoliday\MalaysiaHoliday;
$holiday = new MalaysiaHoliday();
// Get holidays for all states in the current year
$result = $holiday->fromAllState()->get();
header('Content-Type: application/json');
echo json_encode($result, JSON_PRETTY_PRINT) . PHP_EOL;
/**
* Get formatted holiday data
* with formatHolidayData method you can easier read and access
* */
echo "------------------------------------------------" . PHP_EOL;
echo "Formatted Holiday Data:" . PHP_EOL;
$formatted = $holiday->formatHolidayData($result);
echo $formatted . PHP_EOL;