0

This is my xml data

<?xml version="1.0" encoding="iso-8859-1"?>
<smslist>
 <sms>
  <cid>FIRSTCID</cid>
  <mid>FIRSTMID</mid>
  <mb>98389923</mb>
 </sms>
 <sms>
  <cid>SECONDCID</cid>
  <mid>SECONDMID</mid>
  <mb>76445645</mb>
 </sms>
...
</smslist>

How to push cid and mid data to php array like $array = array(("FIRSTCID","FIRSTMID"),("SECONDCID","SECONDMID")...)

Excuse if this is some duplicate question. :)

2 Answers 2

1

you can try this:

$xml = new SimpleXMLElement($your_xml_string);
$xml_array=[];
foreach ($xml->smslist->sms as $sms) {
    $xml_array[]=array($sms->cid,$sms->mid);
}
Sign up to request clarification or add additional context in comments.

Comments

0

By using xml_parse_into_struct() you can convert XML to array, for detailed document check below link.

http://php.net/manual/en/function.xml-parse-into-struct.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.