Hello,
I am parsing through XML documents with a PHP script and creating an array because, as far as I know, I can manipulate arrays better than the features DOM gives me. That part is not as important, though.
The array it produces though is multi-dimensional, but somewhat inconsistent.
If I have the following XML:
PHP Code:
<domains>
<domain>
<title>google.com</title>
<bookmarks>
<bookmark>maps.google.com</bookmark>
<bookmark>news.google.com</bookmark>
<bookmark>mail.google.com</bookmark>
</bookmarks>
</domain>
<domain>
<title>bankaccount.com</title>
<bookmarks>
<bookmark>login.bankaccount.com</bookmark>
</bookmarks>
</domain>
</domains>
To call the first bookmark from the first domain, it would be:
PHP Code:
$array['domains']['domain'][0]['bookmarks']['bookmark'][0]
To call the first bookmark from the second domain, it would be:
PHP Code:
$array['domains']['domain'][1]['bookmarks']['bookmark']
The problem is, I want to simply call bookmarks through a simply 'foreach()' or 'for()' function and the lack of consistency might be a problem, but the fact that some levels have a '0' array key and others do not is causing a problem.