add clear
This commit is contained in:
@@ -31,6 +31,32 @@ class Help extends Miniprogarampage
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function toArray($xml)
|
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)) {
|
if (is_array($xml)) {
|
||||||
return $xml;
|
return $xml;
|
||||||
|
|||||||
Reference in New Issue
Block a user