Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7621971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:20:01+00:00 2026-05-31T04:20:01+00:00

I have this xml that contains four text messages and i have converted that

  • 0

I have this xml that contains four text messages and i have converted that into an array.

The 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>

The array

Array ( [smses] => Array ( [sms] => Array ( [0] => Array ( ) [1] =>
Array ( ) [0_attr] => Array ( [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 ) [1_attr] => Array ( [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 ) [2] =>
Array ( ) [2_attr] => Array ( [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
) [3] => Array ( ) [3_attr] => Array ( [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 ) [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] => Feb 14, 2012 7:42:55 AM [contact_name] => Miguel ) ) ) [smses_attr] => Array (
[count] => 4 ) )

I have another xml doc 2 which i have changed only one value – address=”0800000″ in the first which is address=”0900000″ in the second.When i compare the two arrays using

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);

i get which is not what i was expecting.

Array ( )

I was expecting something like

Array
(
    [1] => 0900000
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:20:02+00:00Added an answer on May 31, 2026 at 4:20 am

    You have a multi-dimsensional array and array_diff only support one dimension.

    From the manual about array_diff:

    This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_diff($array1[0], $array2[0]);.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml file that contains this data: `<?xml version=1.0 encoding=UTF-8?> <WordList> <Words
I have an XML that goes like this: <?xml version=1.0 encoding=utf-8 ?> <colors> <color
I have an xml file that contains a structure.. In this structure, I have
I have an XML that contains information about environment variable to set into the
To start off, I have this XML file that contains recursive parent-child elements. Here
I have this piece of XML that I use in order to create a
What I want to do is this: I have a pom.xml that depends on
I have XML that looks like this: <Parameter Name=parameter name Value=parameter value /> which
I have XML that looks like this: <ROW ref=0005631 type=04 line=1 value=Australia/> <ROW ref=0005631
I have an xml that looks like this: <Config> <A></A> <Template><B/><C/></Template> </Config> and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.