SimpleXMLElement Object的数据有点怪异
里面的array用循环居然读不出来的
有个方式可以:

/**
* function object2array - A simpler way to transform the result into an array
*   (requires json module).
*
* This function is part of the PHP manual.
*
* The PHP manual text and comments are covered by the Creative Commons
* Attribution 3.0 License, copyright (c) the PHP Documentation Group
*
* @author  Diego Araos, diego at klapmedia dot com
* @date    2011-02-05 04:57 UTC
* @link    http://www.php.net/manual/en/function.simplexml-load-string.php#102277
* @license http://www.php.net/license/index.php#doc-lic
* @license http://creativecommons.org/licenses/by/3.0/
* @license CC-BY-3.0 <http://spdx.org/licenses/CC-BY-3.0>
*/
function object2array($object)
{
    return json_decode(json_encode($object), TRUE);
}


据闻xml也可以:
function xmlstring2array($string)
{
    $xml   = simplexml_load_string($string, 'SimpleXMLElement', LIBXML_NOCDATA);

    $array = json_decode(json_encode((array)$xml), TRUE);

    return $array;
}


摘自:http://stackoverflow.com/questions/6167279/converting-a-simplexml-object-to-an-array


原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
发表评论
AD
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐