add clear
This commit is contained in:
+18
-7
@@ -35,23 +35,34 @@ class Help extends Miniprogarampage
|
||||
if (is_array($xml)) {
|
||||
return $xml;
|
||||
}
|
||||
$matchQoute = '/(<\?xml.*?\?>)?<([a-zA-Z_]+)>(<([a-zA-Z_]+)><!.*?><\/\4>)+<\/\2>/';
|
||||
if (!preg_match($matchQoute, $xml)) {
|
||||
return self::jsonToArray($xml);
|
||||
}
|
||||
try {
|
||||
$data = @simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
|
||||
if ($data !== false) {
|
||||
return json_decode(json_encode($data), TRUE);
|
||||
$data = json_decode(json_encode($data), TRUE);
|
||||
} else {
|
||||
$data = $xml;
|
||||
}
|
||||
$data = json_decode($xml, TRUE);
|
||||
} catch (\Exception $exception) {
|
||||
$data = json_decode($xml, TRUE);
|
||||
$data = $xml;
|
||||
} finally {
|
||||
if (is_array($data)) {
|
||||
return $data;
|
||||
}
|
||||
return $xml;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function jsonToArray($xml)
|
||||
{
|
||||
$_xml = json_decode($xml, true);
|
||||
if (is_null($_xml)) {
|
||||
return $xml;
|
||||
}
|
||||
return $_xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $xml
|
||||
* @return mixed
|
||||
|
||||
Reference in New Issue
Block a user