Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 14th, 2013  |  syntax: PHP  |  size: 0.42 KB  |  views: 57  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. function tag($tag, $content = null, array $attributes = null) {
  3.  
  4.    $out = '<{$tag}';
  5.    if ($attributes !== null) {
  6.      foreach($attributes AS $key => $val) {
  7.        $out .= ' {$key}="{$val}"';
  8.      }
  9.    }
  10.  
  11.    if ($content === null) {
  12.       return '{$out}/>';
  13.    }
  14.  
  15.    return '{$out}>{$content}</{$tag}>';
  16.  
  17. }
  18.  
  19. tag('h1', 'Header', array('class' => 'h1', 'id' => 'h1', 'style' => 'text-align:center;'));
clone this paste RAW Paste Data