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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:24:06+00:00 2026-05-21T19:24:06+00:00

I asked a question yesterday about the USE identifier and it was answered PHP

  • 0

I asked a question yesterday about the USE identifier and it was answered PHP 5.3.0 USE keyword — how to backport in 5.2?.

However I’ve had to extend my script to do this twice and unsure how I accommodate both

$available_event_objects  = array_filter($event_objects, function ($event_object) use ($week_events) { 
    // keep if the event is not in $week_events
    return !in_array($event_object, $week_events);
  });`

and

$calendar_weeks[$week_count][$calendar_date] = array_filter($available_event_objects, function ($event_object) use ($date_pointer) { 
    // keep if the event is happening on this day
    return ($date_pointer >= $event_object->start_date && $date_pointer <= $event_object->end_date);
  });`

How can I change this to get it to work in 5.2.9?

Can someone point me in the right direction??

Cheers

  • 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-21T19:24:07+00:00Added an answer on May 21, 2026 at 7:24 pm

    PHP did not have anonymous functions before 5.3. You must use any of the callback types instead. Because this gets more difficult and is not very idiomatic with use cases such as yours, I would advise you to apply an imperative programming style instead.

    $available_event_objects = array();
    foreach ($event_objects as $event_object) {
        if (in_array($event_object, $week_events)) {
            $available_event_objects[] = $event_object;
        }
    }
    

    That said, for this case you can freely use array_intersect, ie. $available_event_objects = array_intersect($week_events, $event_objects);

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

Sidebar

Related Questions

I asked this question yesterday about storing a plot within an object. I tried
This question follows on from a question I asked yesterday about why using the
I had telephone interview question yesterday. The interviewer asked me if I had faced
Yesterday, I asked this question and never really got an answer I was really
This question is related to another question which I asked yesterday! List all links
I asked a question yesterday about password safety... I am new at security... I
I asked a question yesterday about comparing ranges for overlap and its been stuck
I asked this question yesterday: Compare array of words to a textarea input with
Following on from this question I asked yesterday: Can I shorten this regular expression?
This problem is related to This question I asked yesterday. Now it seems that

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.