Jump to content

Making the first article appear differently to the rest


tomhoad

Recommended Posts

Simple question... I've fiddled around with some of the for, do while etc. statements and cant find the one that does what i need it to do.

 

if ($i = 0){
    $output .= '<a target="_new" href="'.$rss->items[$i]['link'].'">'.$rss->items[$i]['title'].'</a><br>';
    $output .= $rss->items[$i]['description'].'<br><br>';
}
echo $output;
for ($i = 1; $i < sizeof($rss->items); $i++){
    $output .= '<a target="_new" href="'.$rss->items[$i]['link'].'">'.$rss->items[$i]['title'].'</a><br>';
}
echo $output;

 

Basically I want to display the full article if it's the first one, and just a list of article titles for the others. I don't think the above code makes logical sense anyway, but I can't seem to figure out what I need

 

Any help app. thanks

the code wasn't working cus your if didn't have a double equal sign. i also rearranged the code a little:

for ($i = 0; $i < count($rss->items); $i++){
  $output .= '<a target="_new" href="'.$rss->items[$i]['link'].'">'.$rss->items[$i]['title'].'</a><br>';
  if ($i == 0){
    $output .= $rss->items[$i]['description'].'<br><br>';
  }
}
echo $output;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.