Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将SimpleXMLObject转换为PHP数组和字符串?_Php_Arrays_Simplexml - Fatal编程技术网

如何将SimpleXMLObject转换为PHP数组和字符串?

如何将SimpleXMLObject转换为PHP数组和字符串?,php,arrays,simplexml,Php,Arrays,Simplexml,考虑以下代码: Array ( [@attributes] => Array ( [Type] => ADSLChecker ) [OperationResponse] => Array ( [PostCode] => E173EQ [ErrorCode] => 0 [FullMsg] => Post

考虑以下代码:

Array
(
    [@attributes] => Array
        (
            [Type] => ADSLChecker
        )

    [OperationResponse] => Array
        (
            [PostCode] => E173EQ
            [ErrorCode] => 0
            [FullMsg] => Postcode only checks will not return any result for fibre services (FTTP, FTTC:VDSL and G.fast).

For all ADSL services, the stable line rate will be determined during the first 10 days of service usage.

Throughput/download speeds will be less than line rates and can be affected by a number of factors within and external to BT's network, Communication Providers' networks and within customer premises.
The Stop Sale date for Datastream is from 30-Jun-2012; the Formal Retirement date for Datastream is from 30-Jun-2014. The Stop Sale date for IPstream is from 30-Nov-2012; the Formal Retirement date for IPstream is from 30-Jun-2014.
            [ExtraMsg] => Please note that postcode and address check results are indicative only. Most accurate results can be obtained from a telephone number, NAD, UPRN or Access Line ID (ALID) check.
Note: If you decide to place an order for a WBC fibre product, an appointment may be required for an engineer to visit the end user's premises to supply the service.


Thank you for your interest.
            [FixedRate] => Array
                (
                    [RAG] => G
                    [ExchangeState] => E
                    [ReasonCode] => Z
                )

            [RateAdaptive] => Array
                (
                    [RAG] => G
                    [ExchangeState] => E
                    [ReasonCode] => Z
                )

            [Max] => Array
                (
                    [RAG] => G
                    [Speed] => 6000
                    [ExchangeState] => E
                    [ReasonCode] => Z
                )

            [WBC] => Array
                (
                    [RAG] => G
                    [Speed] => 11000
                    [ExchangeState] => E
                    [Band] => 1
                    [ReasonCode] => Z
                )

            [AnnexM] => Array
                (
                    [ExchangeState] => E
                    [Band] => 1
                    [ReasonCode] => Z
                )

            [Fttc] => Array
                (
                    [Band] => 1
                )

            [ExchangeCode] => LNWTH
            [ExchangeName] => WALTHAMSTOW
            [ReasonCode] => Z
            [LLU] => Array
                (
                    [Speed] => 0
                    [ExchangeState] => Unknown
                    [ReasonCode] => A
                )

        )

)

$xml=simplexml\u load\u字符串($response);一旦我打印了r($xml);我正在讨论xml对象。如何转换为PHP数组并按kyes打印所有值。SimpleXMLElement的print_r()输出很容易被误解。PHP手册中演示了基本用法:@hakre I已尝试打印_r($xml)$xml=simplexml_load_string($response);一旦我打印了r($xml);并且得到了与resultprint\r相同的上述数组,这只会误导SimpleXML。Fpr示例这些不是数组,尽管打印输出是这样说的。最好只与源XML相关,然后访问XML元素和属性节点,如示例所示。