View difference between Paste ID: 61vfFwkQ and CWB2u1jU
SHOW: | | - or go back to the newest paste.
1
<?php
2-
function tag($tag, $content = null, array $attributes = null) {
2+
function tag($tag, $content = null, array $attributes = array()) {
3
4
   $out = '<' . $tag;
5-
   if ($attributes !== null) {
5+
   foreach($attributes AS $key => $val) {
6-
     foreach($attributes AS $key => $val) {
6+
     $out .= ' ' . $key . '="' . $val . '"';
7-
       $out .= ' ' . $key . '="' . $val . '"';
7+
8-
     }
8+
9
   if ($content === null) {
10
      return $out . ' />';
11
   }
12
13
   return $out . '>' . $content . '</' . $tag . '>';
14
15
}
16
17
tag('h1', 'Header', array('class' => 'h1', 'id' => 'h1', 'style' => 'text-align:center;'));