Combine two foreach loops
Posted: Sun Nov 15, 2015 12:26 pm
Hey there.
I need to display data from two foreach loops together through a table or something. I have a code:
This will output data like this:
And i'd like something like:
I tried few things, but whatever I do looks messy and didn't work well. Any hints please? 
I need to display data from two foreach loops together through a table or something. I have a code:
Code: Select all
$blic_xpath = new DOMXPath($blic_doc);
// getting h4 elements
$podaci_levo = $blic_xpath->query('//h4');
foreach($podaci_levo as $stubic){
echo $stubic->nodeValue;
}
// getting comments from div
$komentari = $blic_xpath->query('//div[@class="inner"]');
foreach($komentari as $kom){
echo $kom->nodeValue;
}
Code: Select all
value1 value2 value3 comment1 comment2 comment3
Code: Select all
value1 comment1
value2 comment2
value3 comment3
...