I'm trying to load a file (an XML file) as an array. I've tried XMLDOM but I was having issues so I decided to just use some php filesystem functions. I tried to load the file as an array, but it didn't work quite right.
Here is the file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<registered_users>
<user suspended="false" suspended_on="null" suspended_for="-1">
<username>someusername</username>
<real>somereal</real>
<password>somepassword</password>
<path>somepath</path>
<registered>somedate</registered>
<activated>anotherdate</activated>
</user>
</registered_users>
Here is the php code used to load it into an array:
$file = file('assets/xmls/database.xml');
var_dump($file);
And here is the result:
array(11) { [0]=> string(45) " " [1]=> string(20) " " [2]=> string(66) " " [3]=> string(37) " someusername " [4]=> string(25) " somereal " [5]=> string(37) " somepassword " [6]=> string(25) " somepath " [7]=> string(37) " somedate " [8]=> string(38) " anotherdate " [9]=> string(10) " " [10]=> string(19) "" }
As you can see, all of the tags are missing. This really isn't a problem as long as my database looks the way it does. But every person who is granted access to this site will have a user tag dedicated to them will all of the data in the user tag above. For that, I will need to search for specific tag names. I know that MySQL would be perfect for this, but some of the later functionalities of this site will store data not ideal for MySQL.
So, how can I load a file into an array without losing all the tags?