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

  • SEARCH
  • Home
  • 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 8824151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:32:15+00:00 2026-06-14T06:32:15+00:00

I have a data structure like this: array (size=10) 1 => array (size=2) ‘fdate’

  • 0

I have a data structure like this:

 array (size=10)
   1 => 
    array (size=2)
     'fdate' => string '11/05/12' (length=8)
     'ftime' => string '11:13' (length=5)
   2 => 
    array (size=2)
    'fdate' => string '11/05/12' (length=8)
    'ftime' => string '11:13' (length=5)
   3 => 
    array (size=2)
     'fdate' => string '11/05/12' (length=8)
     'ftime' => string '11:50' (length=5)
  4 => 
    array (size=2)
     'fdate' => string '11/05/12' (length=8)
     'ftime' => string '11:51' (length=5)
  5 => 
    array (size=2)
     'fdate' => string '11/07/12' (length=8)
     'ftime' => string '09:11' (length=5)
  6 => 
    array (size=2)
     'fdate' => string '11/07/12' (length=8)
     'ftime' => string '09:12' (length=5)
  7 => 
    array (size=2)
     'fdate' => string '11/07/12' (length=8)
     'ftime' => string '10:29' (length=5)
  8 => 
    array (size=2)
     'fdate' => string '11/08/12' (length=8)
     'ftime' => string '11:06' (length=5)
  9 => 
    array (size=2)
    'fdate' => string '11/08/12' (length=8)
    'ftime' => string '11:06' (length=5)
  10 => 
    array (size=2)
    'fdate' => string '11/08/12' (length=8)
    'ftime' => string '11:07' (length=5)

I need to evaluate and end up with the first and last ftime values for each date, in this case

 fdate     ftime1 ftime2
 11/05/12, 11:13, 11:51
 11/07/12, 09:11, 10:29
 11/08/12, 11:06, 11:07

I have a loop like this:

 $struct = array();
 $i = 1;
 foreach($recs as $row){            
   $struct[$i]['fdate'] = $row->fdate;// store fdate
   $struct[$i]['ftime1'] = $row->ftime;// store initial ftime
   $currentfdate = $row->fdate; // use $currentfdate in comparison to $row->fdate

   if($currentfdate <> $row->fdate){
      $struct[$i]['ftime2'] = $row->ftime;// store last ftime
   }

   $i++;
 }

I am not sure how to determine when the fdate changes to trigger the storing of ftime2.

  • 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-14T06:32:17+00:00Added an answer on June 14, 2026 at 6:32 am

    You can try this:

    $temp = array();
    foreach($recs as $row){            
       $temp[$row->fdate][]=$row->ftime;
    }
    
    foreach($temp as $date=>$value){
      echo $date.'-'.current($value).'-'.end($value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an array data structure that I iterate over like this, calling
My table have data structure like this cate_id task_id date_start date_end other 34 14
Using EF4 and Linq I have a data structure which looks like this: parentid
I have a data.table object like this one library(data.table) a <- structure(list(PERMNO = c(10006L,
I have the need to use a Stack-like data structure for a program that
I have a data structure like this ( assume that the data structure is
I have a data structure that looks like this: [ {:choices=>[Hello, Hi]}, , {:choices=>[wor,
I have this array {$man_data} which is structured like 10 > 'Text 8' 14
I'm a bit confused on this. I have a data table structured like this:
I have a set of data that is structured like this: ItemA.GroupA ItemB.GroupA ItemC.GroupB

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.