object(SimpleXMLElement)[9]
public 'result' =>
object(SimpleXMLElement)[8]
public 'err_code' => string '0' (length=1)
public 'model' => string '000000000000^000000000000' (length=26)
public 'success' => string 'true' (length=4)
public 'request_id' => string '000000000000' (length=13)class xml{
/**
* object(SimpleXMLElement) 对象转换为数组
* convert simplexml object to array sets
* $array_tags 表示需要转为数组的 xml 标签。例:array('item', '')
* 出错返回False
*
* @param object $simplexml_obj
* @param array $array_tags
* @param int $strip_white 是否清除左右空格
* @return mixed
*/
public static function toArray($simplexml_obj, $array_tags=array(), $strip_white=1)
{
if( $simplexml_obj )
{
if( count($simplexml_obj)==0 )
return $strip_white?trim((string)$simplexml_obj):(string)$simplexml_obj;
$attr = array();
foreach ($simplexml_obj as $k=>$val) {
if( !empty($array_tags) && in_array($k, $array_tags) ) {
$attr[] = self::toArray($val, $array_tags, $strip_white);
}else{
$attr[$k] = self::toArray($val, $array_tags, $strip_white);
}
}
return $attr;
}
return false;
}
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号