title: How to parse array in php
body: <p>I have to parse following array in php. I am sending an XML file through HTML file and then I got the following array. I have to parse this array to get key values from it. I am sending xml file that will be converted to array and then i have to parse the array. I am using foreach loop for this but didn't able to get inner values like Phone numbers etc</p>
  
  <p>I am using </p>
  
  <pre><code>echo "&lt;pre&gt;";print_r($_FILES);echo "&lt;/pre&gt;";
  $myXMLData = trim(file_get_contents('php://input'));
  //echo 'post action ==== &gt;&gt;&gt; '.$_POST["action"];
  
      if ($_FILES["fileToUpload"]["error"] == 0)
      {
          $filename = $_FILES["fileToUpload"]["tmp_name"];
          //$handle = fopen($filename, "r");
          $xml = simplexml_load_file($filename);    
          //echo "&lt;pre&gt;";print_r($handle);echo "&lt;/pre&gt;";
          //$xml=simplexml_load_string($handle) or die("Error: Cannot create object");
          echo "&lt;pre&gt;";print_r($xml);echo "&lt;/pre&gt;";
          echo "abcdef";
          //echo $xml['fileToUpload']['name'] . "&lt;br /&gt;";
          foreach($xml as $key=&gt;$value)
          {
              echo $key."&lt;/br&gt;";
              if ($key == 'Contact')
              {
                  echo "abcContactttttt";
              }
              elseif($key == 'HomeInsuranceQuote')
              {
                  echo "safszdfzhomeinsurance";
              }
          }
  
          //$xmlDataArray =  (array) $xml;
          //echo "&lt;pre&gt;";print_r($xml);echo "&lt;/pre&gt;";
  
      }
      else{
           echo "File not uploaded successfully ..... " ;
      }
  
  
  Array output is:- 
    SimpleXMLElement Object
      (
          [Contact] =&gt; SimpleXMLElement Object
              (
                  [FirstName] =&gt; John
                  [LastName] =&gt; Doe
                  [Address1] =&gt; 123 Main
                  [City] =&gt; Denver
                  [State] =&gt; CO
                  [ZipCode] =&gt; 80202
                  [EmailAddress] =&gt; test@bankrateinsurance.com
                  [PhoneNumbers] =&gt; SimpleXMLElement Object
                      (
                          [PhoneNumber] =&gt; Array
                              (
                                  [0] =&gt; SimpleXMLElement Object
                                      (
                                          [PhoneNumberValue] =&gt; 3030000000
                                          [PhoneNumberType] =&gt; Home
                                      )
  
                                  [1] =&gt; SimpleXMLElement Object
                                      (
                                          [PhoneNumberValue] =&gt; 3030000001
                                          [PhoneNumberType] =&gt; Mobile
                                      )
  
                                  [2] =&gt; SimpleXMLElement Object
                                      (
                                          [PhoneNumberValue] =&gt; 3030000002
                                          [PhoneNumberType] =&gt; Work
                                      )
  
                              )
  
                      )
  
                  [ResidenceStatus] =&gt; Unknown
              )
  
          [AutoInsuranceQuoteRequest] =&gt; SimpleXMLElement Object
              (
                  [Persons] =&gt; SimpleXMLElement Object
                      (
                          [Person] =&gt; Array
                              (
                                  [0] =&gt; SimpleXMLElement Object
                                      (
                                          [FirstName] =&gt; John
                                          [LastName] =&gt; Doe
                                          [BirthDate] =&gt; 1980-01-01
                                          [Occupation] =&gt; Architect
                                          [HighestDegree] =&gt; Graduate
                                          [CreditHistory] =&gt; SimpleXMLElement Object
                                              (
                                                  [Bankruptcy] =&gt; No
                                                  [CreditSelfRating] =&gt; Unsure
                                                  [Repossessions] =&gt; No
                                              )
  
                                          [Gender] =&gt; Male
                                          [MilitaryExperience] =&gt; Yes
                                          [UsResident12Months] =&gt; Yes
                                          [MaritalStatus] =&gt; Married
                                          [RelationshipToApplication] =&gt; Self
                                          [PersonId] =&gt; 1
                                          [AgeInYears] =&gt; 34
                                          [AgeInMonths] =&gt; 415
                                      )
  
                                  [1] =&gt; SimpleXMLElement Object
                                      (
                                          [FirstName] =&gt; Jane
                                          [LastName] =&gt; Doe
                                          [BirthDate] =&gt; 1981-01-01
                                          [Gender] =&gt; Female
                                          [MaritalStatus] =&gt; Married
                                          [RelationshipToApplication] =&gt; Spouse
                                          [PersonId] =&gt; 2
                                          [AgeInYears] =&gt; 33
                                          [AgeInMonths] =&gt; 403
                                      )
  
                                  [2] =&gt; SimpleXMLElement Object
                                      (
                                          [FirstName] =&gt; James
                                          [LastName] =&gt; Doe
                                          [BirthDate] =&gt; 1996-01-01
                                          [Occupation] =&gt; Student
                                          [HighestDegree] =&gt; Other
                                          [Gender] =&gt; Male
                                          [RelationshipToApplication] =&gt; Child
                                          [PersonId] =&gt; 3
                                          [AgeInYears] =&gt; 19
                                          [AgeInMonths] =&gt; 206
                                      )
  
                              )
  
                      )
          [ReceivedDateTime] =&gt; 2014-06-01T00:00:00
          [Version] =&gt; 1.0
          [ApplicationId] =&gt; 12345
          [RiskType] =&gt; Premium
          [Vertical] =&gt; Auto
      )
  </code></pre>