I am working on a script that lets the user load a remote XML file and lets them choose an element. I then need to be able to retrieve the value of that element a later date. The XML is updated regularly and I want to display the updates value each time.
So far I convert the XML into a multidimensional array, display the elements and their values to the user, and when they choose an element I save the keys of the multidimensional array.
So for example if we have the following array:
Array
(
[responsecode] => 0
[message] =>
[items] => Array
(
[0] => Array
(
[title] => Example1
[content] => This is the first message
[date] => 00/00/00
)
[1] => Array
(
[title] => Example2
[content] => This is the second message
[date] => 00/00/00
)
)
)
If the user chooses the first title element I save the path as follows:
$path = "itmes>0>title";
I then explode the string to get the separate keys:
$keys = explode(">", $path);
Array
(
[0] => items
[1] => 0
[2] => title
)
If I wanted to read the value manually I would use:
array['items']['0']['title']
But how would I build that query when I have an array of they keys?