我有这个包含四个文本消息的 xml,并且我已将其转换为一个数组。
xml
> <?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
> <?xml-stylesheet type="text/xsl" href="sms.xsl"?> <smses count="4">
> <sms protocol="0" address="0800000" date="1328814938421" type="2"
> subject="null" body="Its raining cat and dogs;and their owners."
> toa="null" sc_toa="null" service_center="null" read="1" status="-1"
> locked="0" date_sent="null" readable_date="Feb 9, 2012 10:15:38 PM"
> contact_name="Hans Petit" />
> <sms protocol="0" address="08005678" date="1328814938421" type="2" subject="null" body="Hello,Andy.The attachment wasn't
> sent.Please resend." toa="null" sc_toa="null" service_center="null"
> read="1" status="-1" locked="0" date_sent="null" readable_date="Feb 9,
> 2012 10:15:38 PM" contact_name="Mary The Great" />
> <sms protocol="0" address="080091011" date="1328814938421" type="2" subject="null" body="Lorem Ipsum = Good Night." toa="null"
> sc_toa="null" service_center="null" read="1" status="-1" locked="0"
> date_sent="null" readable_date="Feb 9, 2012 10:15:38 PM"
> contact_name="Ed Myers" />
> <sms protocol="0" address="+44839202" date="1328815215841" type="1" subject="null" body="I represent a variable." toa="null"
> sc_toa="null" service_center="+4422500000" read="1" status="-1"
> locked="0" date_sent="null" readable_date="Feb 9, 2012 10:20:15 PM"
> contact_name="Dexter" />
> <sms protocol="0" address="+2273839309" date="1329194575094" type="1" subject="null" body="Take it easi" toa="null" sc_toa="null"
> service_center="+4422500000" read="1" status="-1" locked="0"
> date_sent="null" readable_date="Feb 14, 2012 7:42:55 AM"
> contact_name="Miguel" /> </smses>
数组
Array ( [smses] => Array ( [sms] => Array ( [0] => Array ( ) [1] => Array ( ) [0_attr] => Array ( [protocol] => 0 [address] => 0800000 [date] => 1328814938421 [type] => 2 [subject] => null [body] => 它下雨的猫狗;以及它们的主人。 [toa] => null [sc_toa] => null [service_center] = > null [read] => 1 [status] => -1 [locked] => 0 [date_sent] => null [readable_date] => 2012 年 2 月 9 日晚上 10:15:38 [contact_name] => Hans Petit) [1_attr] => Array ( [protocol] => 0 [address] => 08005678 [date] => 1328814938421 [type] => 2 [subject] => null [body] => 你好,Andy。附件是' t 已发送。请重新发送。[toa] => null [sc_toa] => null [service_center] => null [read] => 1 [status] => -1 [locked] => 0 [date_sent] =>null [可读日期] => 2012 年 2 月 9 日晚上 10:15:38 [contact_name] => Mary The Great ) [2] => Array ( ) [2_attr] => Array ( [protocol] => 0 [address] = > 080091011 [日期] => 1328814938421 [类型] => 2 [主题] => null [正文] => Lorem Ipsum = 晚安。[toa] => null [sc_toa] => null [service_center] => null [阅读] => 1 [状态] => -1 [锁定] => 0 [日期发送] => 空 [可读日期] => 2012 年 2 月 9 日晚上 10:15:38 [联系人姓名] => Ed Myers) [3] => Array ( ) [3_attr] => Array ( [protocol] => 0 [address] => +44839202 [date] => 1328815215841 [type] => 1 [subject] => null [body] => 我代表一个变量。[toa] => null [sc_toa] => null [service_center] => +4422500000 [read] => 1 [status] => -1 [locked] => 0 [date_sent] =>null [可读日期] => 2012 年 2 月 9 日晚上 10:20:15 [contact_name] => Dexter ) [4] => Array ( ) [4_attr] => Array ( [protocol] => 0 [address] => + 2273839309 [date] => 1329194575094 [type] => 1 [subject] => null [body] => Take it easi [toa] => null [sc_toa] => null [service_center] => +4422500000 [read] = > 1 [status] => -1 [locked] => 0 [date_sent] => null [readable_date] => 2012 年 2 月 14 日上午 7:42:55 [contact_name] => Miguel ) ) ) [smses_attr] =>数组 ( [count] => 4 ) )+4422500000 [read] => 1 [status] => -1 [locked] => 0 [date_sent] => null [readable_date] => 2012 年 2 月 14 日上午 7:42:55 [contact_name] => Miguel ) ) [smses_attr] => 数组 ([count] => 4))+4422500000 [read] => 1 [status] => -1 [locked] => 0 [date_sent] => null [readable_date] => 2012 年 2 月 14 日上午 7:42:55 [contact_name] => Miguel ) ) [smses_attr] => 数组 ([count] => 4))
我有另一个xml doc 2,我只更改了一个值-第一个值是address="0800000",第二个是address="0900000"。当我使用比较两个数组时
include "xml2array.php";
$contents = file_get_contents('sms.xml');//Or however you what it
$result = xml2array($contents);
//print_r($result);
$contents_ = file_get_contents('smsz.xml');//Or however you what it
$result_ = xml2array($contents_);
//print_r($result_);
$result_diff = array_diff($result, $result_);
print_r($result_diff);
我明白了,这不是我所期待的。
大批 ( )
我期待类似的东西
Array
(
[1] => 0900000
)