loops - PHP foreach with two 'as'? -


hi there trying combine 2 loops of foreach have problem.

the problem <a href='$link'> same results must different.

here code using:

<?php $feed = file_get_contents('http://grabo.bg/rss/?city=&affid=16090');  $rss = simplexml_load_string($feed);  $doc = new domdocument(); @$doc->loadhtml($feed);  $tags = $doc->getelementsbytagname('link');  foreach ($tags $tag) {     foreach($rss $r){         $title = $r->title;         $content = $r->content;         $link = $tag->getattribute('href');         echo "<a href='$link'>$title</a> <br> $content";     } }  ?> 

where mistake? why it's not working , how make work properly? in advance!

both loops going through different resources cross joining records in them.

this should work data need:

<?php $feed = file_get_contents('http://grabo.bg/rss/?city=&affid=16090'); $rss = simplexml_load_string($feed);  foreach ($rss $key => $entry) {     if ($key == "entry")     {         $title = (string) $entry->title;         $content = (string) $entry->content;         $link = (string) $entry->link["href"];         echo "<a href='$link'>$title</a><br />" . $content;     } } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -