PHP Classes

File: examples/tags/date/tag.php

Recommend this page to a friend!
  Classes of Oliver Lillie  >  PHP Custom Tags  >  examples/tags/date/tag.php  >  Download  
File: examples/tags/date/tag.php
Role: Auxiliary script
Content type: text/plain
Description: Example script
Class: PHP Custom Tags
Template engine based on tags similar to HTML
Author: By
Last change: Update of examples/tags/date/tag.php
Date: 11 months ago
Size: 779 bytes


Class file image Download

namespace CustomTags;

ct_date($tags, $source)
// loop through all the tags and capture the block source and the
// replacement value so they can be bulk replaced
$replacements = array();
        foreach (
$tags as $tag)
$format = isset($tag['attributes']['format']) ? $tag['attributes']['format'] : 'd.m.Y';
$replacements[$tag['tag']] = isset($tag['attributes']['timestamp']) ? date($format, $tag['attributes']['timestamp']) : date($format);
strtr($source, $replacements);
// this signals that the tag should be processed as a collection, meaning
// that the argument supplied to the function is an array of tags and not
// a single tag. The collected tags will be processed at the end of the parse.
$collect = true;

For more information send a message to info at phpclasses dot org.