Unparsing HTML

From: Date: Thu, 15 Jun 2000 17:37:20 +0000
Subject: Unparsing HTML
Groups: php.general 
Request: Send a blank email to php-general+get-1967@lists.php.net to get a copy of this message
I'm in the process of writing the same old same old stupid code, something like this: function _($tag, $attributes='', $content='') { $html = '<'.$tag; if (is_array($attributes)) { while ($attribute = each($attributes)) { if (is_int($attribute[1])) { $html .= ' '.$attribute[0].'='.$attribute[1]; } elseif (is_string($attribute[1])) { $html .= ' '.$attribute[0].'="'.$attribute[1].'"'; } elseif ($attribute[1]) { $html .= ' '.$attribute[0]; } } } else { $content = $attributes.$content; } if ($content) { return $html.'>'.$content.'</'.$tag.'>'; } else { return $html.'>'; } } Now I can't imagine that I'd be the first to do this, and I'm also seeing that this whole thing is going to end up being quite inefficient. All these string concatenations... Anyway, how come PHP doesn't have built in support for HTML (or XML) parse trees and functions to build them, store them and dump them efficiently? -- cg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#1967) next »