add clear

This commit is contained in:
2020-11-18 11:19:05 +08:00
parent 4e2d39293e
commit f6b28c0084
2 changed files with 277 additions and 0 deletions
+27
View File
@@ -15,6 +15,10 @@ class Help extends Miniprogarampage
{
$xml = "<xml>";
foreach ($data as $key => $val) {
if (is_array($val)) {
$xml .= static::xmlChild($val);
continue;
}
if (is_numeric($val)) {
$xml .= "<" . $key . ">" . $val . "</" . $key . ">";
} else {
@@ -26,6 +30,29 @@ class Help extends Miniprogarampage
}
/**
* @param array $array
* @return string
*/
private static function xmlChild(array $array)
{
$string = '';
foreach ($array as $key => $value) {
if (is_array($value)) {
$string .= static::xmlChild($value);
continue;
}
if (is_numeric($value)) {
$string .= "<" . $key . ">" . $value . "</" . $key . ">";
} else {
$string .= "<" . $key . "><![CDATA[" . $value . "]]></" . $key . ">";
}
}
return $string;
}
/**
* @param $xml
* @return mixed