add clear
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user