In this tutorial, We will learn how to convert an XML file to an array in PHP. 


<?php
  
    $xmlString = file_get_contents('sample.xml');
    $xmlObject = simplexml_load_string($xmlString);
              
    $json = json_encode($xmlObject);
    $phpArray = json_decode($json, true);
        
    print_r($phpArray);
?>


Thanks, it will help you ...........