I'm reading data from an xml file. I am able to get the elements I need from the xml file, but I need to put them into a multi-dimensional array to access later in the script.
Using the example below, each line of output gives me "Movie" or "Session" (which will be the main array name); the element name ("movie_id", "movie_title"); the element value ("15", "Abduction"); and the $i value associates with each specific session or movie.
My array should look like this:
$Movie[movie_property][$i] = $movie_property
OR
$Movie[movie_title][0] = Abduction (If I have 7 movies it will be $Movie[movie_title][0-6])
$Movie[movie_id][0] = 15
Then later it will be:
$Session[session_id][0] = 100
$Session[movie_id][0] = 15
Because I know the structure of the XML file, I could simply hard code the arrays with the known information and only read in the variables (i.e. $Movie[movie_id][$i] = $movie_id). But I would like to make the script robust enough so if the XML feed changes I'll still get the same output.
Later I'm going to need to loop through both of these arrays to add their values into a database.
Using the example below, each line of output gives me "Movie" or "Session" (which will be the main array name); the element name ("movie_id", "movie_title"); the element value ("15", "Abduction"); and the $i value associates with each specific session or movie.
My array should look like this:
$Movie[movie_property][$i] = $movie_property
OR
$Movie[movie_title][0] = Abduction (If I have 7 movies it will be $Movie[movie_title][0-6])
$Movie[movie_id][0] = 15
Then later it will be:
$Session[session_id][0] = 100
$Session[movie_id][0] = 15
Because I know the structure of the XML file, I could simply hard code the arrays with the known information and only read in the variables (i.e. $Movie[movie_id][$i] = $movie_id). But I would like to make the script robust enough so if the XML feed changes I'll still get the same output.
Later I'm going to need to loop through both of these arrays to add their values into a database.