add clear

This commit is contained in:
as2252258@163.com
2020-03-10 16:09:59 +08:00
parent ea822241a1
commit 535d3b3e82
+26
View File
@@ -31,6 +31,32 @@ class Help extends Miniprogarampage
* @return mixed
*/
public static function toArray($xml)
{
if (is_array($xml)) {
return $xml;
}
try {
$data = @simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
if ($data !== false) {
return json_decode(json_encode($data), TRUE);
}
$data = json_decode($xml, TRUE);
} catch (\Exception $exception) {
$data = json_decode($xml, TRUE);
} finally {
if (is_array($data)) {
return $data;
}
return $xml;
}
}
/**
* @param $xml
* @return mixed
*/
public static function xmlToArray($xml)
{
if (is_array($xml)) {
return $xml;