1

Possible Duplicate:
PHP: Best way to iterate two parallel arrays?

I am using PHP DOMDocument to parse some html data frm a football bet-site.

I have one Xpath searching for the home-team and another searching for the away-team.

When i get the data in the variables $teamHome and $teamAway i want to do something like this:

foreach($teamHome as team1)&&($teamAway as team2){
    echo $team1->nodeValue . " vs " . $team2->nodeValue . "\n";
}

Is there any way to do it? Thanks

Community
  • 1
  • 1
Manos Serifios
  • 577
  • 2
  • 7
  • 22
  • If `MultipleIterator` is not what you are looking for, see if an [AppendIterator](http://stackoverflow.com/questions/10619315/combine-two-xml-php) will do. – Gordon Oct 28 '12 at 18:45
  • Check the examples at http://php.net/MultipleIterator and http://php.net/AppendIterator on the pages for `__construct()` – Gordon Oct 28 '12 at 18:46
  • On a sidenote, you can join two XPath queries by using the UNION operator between them, e.g. `//foo | //bar` which would give you the results in one DOMNodeList – Gordon Oct 28 '12 at 18:48
  • @Gordon Thanks for your answers. The pipe solution doesn't help me because i want in every loop 2 nodeValues. The multipleiterotor solution is intersting. Can u give an example? is it gonna work for nodelist or is only for arrays. I didnh know that exist before 30mins.. Thanks anyway! – Manos Serifios Oct 28 '12 at 19:24

0 Answers0