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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:31:01+00:00 2026-05-31T15:31:01+00:00

I have following php function, that creates an array of all the days between

  • 0

I have following php function, that creates an array of all the days between a start date and an end date:

function dateRange( $first, $last, $step = '+1 day', $format = 'Y-m-d' ) {

$dates = array();
$current = strtotime( $first );
$last = strtotime( $last );

while( $current <= $last ) {

    $dates[] = date( $format, $current );
    $current = strtotime( $step, $current );
    }

    return $dates;
}

I then use:

if (in_array($this_date,dateRange($start_date, $end_date))) {... do sth ...} else {... do sth else...}

Now I think to best implement this in a while-loop when reading the dates from the database. There are several date periods in the database and I would like to create an array with all of them when reading the rows, and finally check if in_array($this_array_contains_all_date_ranges_from_db).

If I try to print $array after using dateRange($start_date,$end_date), it returns only an empty “Array”. However, if I use the above mentioned if, it works fine. Also, I tried e.g. $this_date_range=dateRange($start_date,$end_date); but it was empty as well… I am not so experienced with functions, so I just could not figure out how can I create a var that will contain all the date ranges?

Thank you very much in advance!! 🙂

  • 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-31T15:31:02+00:00Added an answer on May 31, 2026 at 3:31 pm

    When you say “print $array”, are you doing a literal print($array)? Getting Array as the output from that is expected – you cannot print() an array. You have to use print_r() or var_dump(). Both will dump data structures into a textual format.

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

Sidebar

Related Questions

I have the following php array that gets all values from a form full
All, I have the following JSON Request that comes through a function call in
Is there a PHP function that will do the following: Move a specified array
I have the following php script that is called by jquery ajax function report_range($time,
I have the following scenario jQuery('#content').fadeOut('slow',function(){ jQuery('#content').load(detail.php?product=+imgID+&category=+cat); jQuery('#content').fadeIn('fast'); }); My problem however is that
I have code with the following form: <?php function doSomething{ //Do stuff with MySQL
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following javascript: $('#ge-display').click(function (event) { window.open('/googleearth/ge-display.php','','scrollbars=yes,menubar=no,height=650,width=1000,resizable=yes,toolbar=yes,location=no,status=no'); event.stopPropagation(); return false; }); the
I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
I have the following code that creates two objects (ProfileManager and EmployerManager) where the

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.