4 つのテキスト メッセージを含むこの 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>
配列
配列 ( [smses] => 配列 ( [sms] => 配列 ( [0] => 配列 ( ) [1] => 配列 ( ) [0_attr] => 配列 ( [プロトコル] => 0 [アドレス] => 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 PM [contact_name] => Hans Petit ) [1_attr] => Array ( [protocol] => 0 [address] => 08005678 [date] => 1328814938421 [type] => 2 [subject] => null [body] => Hello, Andy.The attachment was' t sent.Please resend. [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 PM [contact_name] => Mary The Great ) [2] => 配列 ( ) [2_attr] => 配列 ([プロトコル] => 0 [アドレス] = > 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] => 2012 年 2 月 9 日 10:15:38 PM [contact_name] => 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 [連絡先名] => デクスター) [4] => 配列 () [4_attr] => 配列 ([プロトコル] => 0 [アドレス] => + 2273839309 [date] => 1329194575094 [type] => 1 [subject] => null [body] => 気軽にどうぞ [toa] => null [sc_toa] => null [service_center] => +4422500000 [read] = > 1 [ステータス] => -1 [ロック済み] => 0 [送信日] => null [読み取り可能日] => 2012 年 2 月 14 日 7:42:55 AM [連絡先名] => ミゲル ) ) ) [smses_attr] =>配列 ( [カウント] => 4 ) )+4422500000 [読み取り] => 1 [ステータス] => -1 [ロック済み] => 0 [送信日] => null [読み取り可能日付] => 2012 年 2 月 14 日 7:42:55 AM [連絡先名] => ミゲル ) ) ) [smses_attr] => 配列 ( [count] => 4 ) )+4422500000 [読み取り] => 1 [ステータス] => -1 [ロック済み] => 0 [送信日] => null [読み取り可能日付] => 2012 年 2 月 14 日 7:42:55 AM [連絡先名] => ミゲル ) ) ) [smses_attr] => 配列 ( [count] => 4 ) )
私は1つの値のみを変更した別のxml doc 2を持っています.1つ目はaddress="0800000"で、2つ目は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
)