stryker Posted August 24, 2007 Posted August 24, 2007 <?php function html($element, $attributes=false, $tabs=0, $newline=false) { // Number of spaces to use for tabs $tabstop = 4; // Check to see if any tabs are needed if($tabs > 0){ $tab = $tabstop * $tabs; for($x = 0;$x < $tab;$x++){ $spaces .= " "; } } print "$spaces<"; // Do we need to print a new line at the end if($newline == true){ $new = "\n"; } // print $element; // Do we have any attributes we need to add if($attributes){ $args = split(" ",$attributes); for($x = 0;$x < count($args);$x++){ $i = split("=",$args[$x]); if(strtoupper($i[0]) == "NOWRAP"){ print " nowrap"; } else if(strtoupper($i[0]) == "SELECTED"){ print " selected"; } else if(strtoupper($i[0]) == "CHECKED"){ print " checked"; } else{ print " $i[0]=\"$i[1]\""; } } } // Finish up print ">$new"; } // Example html("html", "", "", true); html("head", "", 1, true); html("title", "", 2); print "Example"; html("/title", "", 0, true); html("/head", "", 1, true); html("body", "bgcolor=white", 1, true); print "Hello World!\n"; html("/body", "", 1, true); html("/html", "", 0, true); ?> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.