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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:17:39+00:00 2026-05-25T15:17:39+00:00

What is causing the second function to miss the last item of the second

  • 0

What is causing the second function to miss the last item of the second array?

$x = array(
  'Mon Sep 12 12:19:33 +0000 2011',
  'Tue Sep 13 14:19:33 +0000 2011',
  'Wed Sep 14 01:19:33 +0000 2011',
  'Thu Sep 15 07:19:33 +0000 2011',
  'Fri Sep 16 16:19:33 +0000 2011',
  'Fri Sep 16 19:19:33 +0000 2011',
  'Sat Sep 17 15:57:37 +0000 2011',
  'Sun Sep 18 13:01:39 +0000 2011', 
  'id' => array('a','b')
);

//Create function to turn timestamps into unix timestamps so
function textTimeToUnixTime($x) {
  $z = array();
  for($i = 0; $i < count($x) - 1; $i++) {
    array_push($z, strtotime($x[$i]));
  }
  return $z;
}

function timeDifference($x)  {
  //Get Time Difference of the timestamps
  array_reverse($x);
  $z = array();
  for($i = 0; $i < count($x) - 1; $i++) {
    $a = $x[$i+1] - $x[$i];
    array_push($z, $a);
  }
  return $z;
}

Output

array(8) {
  [0]=> int(1315829973) 
  [1]=> int(1315923573) 
  [2]=> int(1315963173) 
  [3]=> int(1316071173) 
  [4]=> int(1316189973) 
  [5]=> int(1316200773) 
  [6]=> int(1316275057) 
  [7]=> int(1316350899)
} 

array(7) {
  [0]=> int(93600) 
  [1]=> int(39600) 
  [2]=> int(108000) 
  [3]=> int(118800) 
  [4]=> int(10800) 
  [5]=> int(74284) 
  [6]=> int(75842)
} 
  • 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-25T15:17:40+00:00Added an answer on May 25, 2026 at 3:17 pm

    Because in timeDifference the last loop it calls $x[7+1] but there’s no such $x[8] but rather a $x[‘id’] so it only works until 7.

    Anyway, if you’re comparing one time with the next one, the ammount of differences should be 1 less than the ammount of times.

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

Sidebar

Related Questions

I can't for the life of me figure out why this function is causing
This is the first part of a function I have that's causing my program
I have a function which grows an array when trying to add an element
The following code is causing an intermittent crash on a Vista machine. using (SoundPlayer
The following code is causing me some problems. The third line causes a program
It is causing so much trouble in terms of development just by letting database
fclose() is causing a segfault. I have : char buffer[L_tmpnam]; char *pipeName = tmpnam(buffer);
I have an application that is causing a lot of headaches. It's a .NET
The following linq2sql code is causing me much headache and I was hoping someone
Can anyone tell me what is causing the space below the images? There seems

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.