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 8516707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:30:20+00:00 2026-06-11T05:30:20+00:00

I am building a calendar application which will allow our admin team to input

  • 0

I am building a calendar application which will allow our admin team to input staff holidays, training days, sick days etc and all staff to view who is in/out on any given day. The calendar is built as is the mechanism to record days off. I’m struggling to display who is off when. Using print_r I get the following back from the server, showing name, date and reason for absence:

Array ( 
[0] => stdClass Object ( [name] => Becca [date] => 2012-10-10  [reason] => Sick ) 
[1] => stdClass Object ( [name] => Frank [date] => 2012-09-12 [reason] => Sic ) 
[2] => stdClass Object ( [name] => Frank [date] => 2012-10-14 [reason] => Sic ) 
[3] => stdClass Object ( [name] => Paola [date] => 2012-10-10 [reason] => Sic ) 
[4] => stdClass Object ( [name] => Clive [date] => 2012-10-14 [reason] => Hol ) ) 

I can iterate through and display some of the names and dates, but if more than one person is off on a given date (eg Becca, Paola), only the last name is displayed, I believe because the key must be unique. The following code does this, where ‘date(“Y-m-d”, $date)’ is the means of printing the dates on the calendar :

foreach ($absenceArray as $dateofabsence=>$name){
    if (date("Y-m-d", $date) == $dateofabsence){
        $showname[$x] = $name; 
    }   
}   

Can someone please demonstrate how I can iterate through the above array and link each name to a corresponding date in my calendar.

I apologise that I no doubt have not explained myself properly but my brain is frazzled.

  • 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-06-11T05:30:22+00:00Added an answer on June 11, 2026 at 5:30 am

    When iterating through this array, the key will be numeric and the ‘value’ will be an object, as you can see in the print_r dump. So the way to go will be like:

    $showname = array();
    foreach($absenceArray as $object)
    {
      if(date("Y-m-d", $date) === $object->date)
      {
        $showname[] = $object->name;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a calendar which shows how busy members of a team are on
I am building a application which takes a backup of calendar & restores it
I'm building a Zend-based Web app that will permit third-party extensions. Essentially, this application's
I'm building my first application that requires a calendar. I have it working great
Pretty new to rails. Building a hypothetical little application to show employees' vacation days
I'm building a calendar, and one of the requirements is to highlight certain days
I'm building a web calendar application and I'm trying to add a feature that
In my Ruby on Rails application I am building a calendar with Fullcalendar JQuery
I am building a calendar website ( ASP.NET MVC ) application (think simple version
I'm building an alarm application. I have successfully implemented basic alarm functions. Calendar calendar

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.