PHP Classes

File: examples/example1.php

Recommend this page to a friend!
  Classes of Marcos Sigueros   Stupidly Simple PHP Calendar   examples/example1.php   Download  
File: examples/example1.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Stupidly Simple PHP Calendar
Render calendars as arrays of time elements
Author: By
Last change: Update of examples/example1.php
Date: 6 days ago
Size: 2,237 bytes


Class file image Download
 * To execute this example you need to install the library with composer in order
 * to use the autoload in this include file.
 * If you dont wanna use composer just include each file from the src directory.
//include 'calendar/src/SSC/Calendar.php';
//include 'calendar/src/SSC/CalendarConfig.php';
//include 'calendar/src/SSC/formatters/FormatterInterface.php';
//include 'calendar/src/SSC/formatters/ArrayFormatter.php';
//include 'calendar/src/SSC/formatters/ObjectFormatter.php';
//include 'calendar/src/SSC/formatters/JsonFormatter.php';

include '../vendor/autoload.php';

$cal = new \SSC\Calendar();

$cal->day_callback = function($date){
$day = new stdClass();
$day->has_passed = $date->getTimestamp()<time();

$structure = $cal->getCalendarStructure();

<h1>Spanish calendar</h1>

<?php foreach($structure as $year): ?>
<?php foreach($year['elements'] as $quarter): ?>
<?php foreach($quarter['elements'] as $month): ?>
                <?php echo $year['value']; ?> - <?php echo $month['value']; ?>
                    <?php foreach($month['elements'] as $week): ?>
                            <?php foreach(array(1,2,3,4,5,6,0) as $weekday): ?>
                                <?php foreach($week['elements'] as $day): ?>
<?php if($day['weekday'] == $weekday): ?>
<?php echo $day['value'];?>
<?php endif; ?>
<?php endforeach; ?>
                            <?php endforeach; ?>
                    <?php endforeach; ?>
        <?php endforeach; ?>
<?php endforeach; ?>
endforeach; ?>