replace xml_tag with HTMLElement

This commit is contained in:
Shish
2020-10-24 13:24:28 +01:00
parent c29fe0583f
commit 9b878d98d6
3 changed files with 21 additions and 43 deletions

View File

@ -190,8 +190,8 @@ function stream_file(string $file, int $start, int $end): void
}
}
if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/function.http-parse-headers.php#112917
# http://www.php.net/manual/en/function.http-parse-headers.php#112917
if (!function_exists('http_parse_headers')) {
/**
* #return string[]
*/
@ -478,25 +478,6 @@ function clamp(?int $val, ?int $min=null, ?int $max=null): int
return $val;
}
function xml_tag(string $name, array $attrs=[], array $children=[]): string
{
$xml = "<$name ";
foreach ($attrs as $k => $v) {
$xv = str_replace('&#039;', '&apos;', htmlspecialchars((string)$v, ENT_QUOTES));
$xml .= "$k=\"$xv\" ";
}
if (count($children) > 0) {
$xml .= ">\n";
foreach ($children as $child) {
$xml .= xml_tag($child);
}
$xml .= "</$name>\n";
} else {
$xml .= "/>\n";
}
return $xml;
}
/**
* Original PHP code by Chirp Internet: www.chirp.com.au
* Please acknowledge use of this code by including this header.