I cannot figure out a way to cut this down to one loop. The processing in each loop is identical. I'd show what I've tried but I can't even get my head around what to try.
<?
if($xml->entry){
foreach ($xml->entry as $item) {
...
}
else{
foreach($rss->channel->item as $item) {
...
}
}
CodePudding user response:
foreach (($xml->entry ? $xml->entry : $rss->channel->item) as $item) {
...
}
CodePudding user response:
$items = $xml->entry ? $xml->entry : $rss->channel->item;
foreach( $items as $item ) {
...
}