Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 390245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:56:45+00:00 2026-05-12T15:56:45+00:00

All right, this must be an absolutely easy question, and I apologize for that.

  • 0

All right, this must be an absolutely easy question, and I apologize for that.

I also apologize if I simply failed in finding the right search terms to use to come to an answer on my own. I did try, but my lack of fluency in PHP kind of makes me suck at searching.

I’m looking for a simple way to show each date only once within a foreach loop. I’m looping through data like so:

<?php
  echo "<ul>";
  foreach($rss_items as $i){
   if($i->get_feed()->get_title() == 'Twitter (no @ replies)'){
   echo "<li>";
   echo $i->get_date();
   echo "<a href='" .$i->get_link()."'>Twitter</a>";
   echo $i->get_title();
   echo "</li>";
   }
   elseif($i->get_feed()->get_title() == 'Pinboard (jpcody)'){
   echo "<li>";
   echo $i->get_date();
   echo "<a href='" .$i->get_link()."'>Pinboard</a>";
   echo $i->get_title();
   echo "</li>";
   }
   elseif($i->get_feed()->get_title() == 'Entries at Church Marketing Sucks by Joshua Cody'){
   echo "<li>";
   echo $i->get_date();
   echo "<a href='" .$i->get_link()."'>Church Marketing Sucks</a>";
   echo "<a href='" .$i->get_link()."'>" . $i->get_title() . "</a>";
   echo $i->get_description();
   echo "</li>";
   }
   elseif($i->get_feed()->get_title() == 'Flickr remove first paragraph'){
   echo "<li>";
   echo $i->get_date();
   echo "<a href='" .$i->get_link()."'>Flickr</a>";
   echo "<a href='" .$i->get_link()."'>" . $i->get_title() . "</a>";
   echo $i->get_description();
   echo "</li>";
   }
  }
  echo "</ul>";
 ?>

And each item contains the date, so I’m getting the same date multiple times. I’d like to only have each date shown once, a la http://daringfireball.net.

I’m using CodeIgniter and the SimplePie library, so all of the data is being pulled directly instead of being stored in a db. I imagine a way to do it could be including a second if statement to check if the date has already been used, but I don’t know how to execute this.

I’m pretty new to PHP, and I’m really looking to learn more than just have a solution given.

Any help you could give would be great!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:56:45+00:00Added an answer on May 12, 2026 at 3:56 pm

    You need to remember what was the date you used last, and print it only if it differs. You can try something like:

    $previous_date = null;
    foreach ($rss_items as $item) {
        if ($item->get_date() != $previous_date) {
            $previous_date = $item->get_date();
            echo '<li>' . $previous_date . '</li>';
        }
        ...
    }
    

    (And don’t forget to HTML-encode the titles and links using htmlspecialchars.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want add my custom sidebar next right column all page. Please check this
First of all I don't know if this is the right approach. I want
Right so, I'm not particularly skilled at this at all, this is in fact
All right all, So I've got a UITableView that is inited in applicationDidFinishLaunching like
I know that somewhere in the history of the internet this must have been
I know this must be an age-old, tired question, but I cant seem to
All right, so previously I asked... SOAP Prototype AJAX SOAPAction Header Question (can't hyperlink
I know this must be asked a millions times and can't be easy to
This must be an easy one but I'm really at a loss... The following
All right, I'll try to explain my problem as clearly as I can. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.