note 57122 deleted from control-structures.foreach by danbrown
| From: | danbrown@php.net | Date: | Tue, 28 Apr 2009 13:08:34 +0000 |
| Subject: | note 57122 deleted from control-structures.foreach by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153918@lists.php.net to get a copy of this message | ||
Note Submitter: Oto "Zver" Brglez ml.
----
You can use you'r own function for creating xml/html tags.
Function :
function tag($tag,$string,$atrib = false){
if(!is_array($atrib)){
return "<".$tag.">".$string."</".$tag.">";
} else {
$o = "<".$tag;
foreach($atrib as $key => $val){
$o .= " ".$key."=\"".$val."\"";
};
$o .= ">".$string."</".$tag.">";
return $o;
};
}
Usage:
$array[href] = "http://www.php.net";
$array[id] = "testcss";
$array[class] = "simplecssclass";
print(tag("a","PHP Home Page,$array));
Output:
<a href="http://www.php.net"
id="testcss" class="simplecssclass">PHP Home Page</a>
You can use this function without attributes. Like this:
print(tag("b",Bold text));
Output:
<b>Bold text</b>