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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:12:34+00:00 2026-05-24T11:12:34+00:00

I believe this code that is used to sort events as folows is giving

  • 0

I believe this code that is used to sort events as folows is giving me an issue. The errors it is triggering is :

Notice: Undefined variable: combined in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 941

Notice: Undefined offset: 3 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 893

Notice: Undefined offset: 3 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 895

Notice: Undefined variable: combined in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 941

Notice: Undefined offset: 4 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 893

Notice: Undefined offset: 4 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 895

Notice: Undefined variable: combined in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 941

Notice: Undefined offset: 5 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 893

Notice: Undefined offset: 5 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 895

Notice: Undefined variable: combined in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 941

Notice: Undefined offset: 6 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 893

Notice: Undefined offset: 6 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 895

Notice: Undefined variable: combined in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 941

Notice: Undefined offset: 7 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 893

Notice: Undefined offset: 7 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 895

Notice: Undefined variable: combined in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 941

Notice: Undefined offset: 8 in /services10/webpages/c/m/cms.norlink.ca/public/admin/new_events.php on line 893

The code is the following:

  function sortevents($days_events)
        {
    if (!is_array($days_events))
    {
        return array();
    }
    if (0 === ($ec=count($days_events)))
    {
        return array(); 
    }
    $neworder = array();
    $oldorder_used = array();
    $allordered = false;
    for ($i = 0; $i <= $ec; $i++)
    { 
        $oldorder_used[$i] = false; 
    }
    $i = 0;
    $sd = null;
    $si = -1;
    $ei = 0;
    while (!$allordered)
    {
        if ((null == $sd || $sd > $days_events[$i]['startint']) && !$oldorder_used[$i])
        {
            $sd = $days_events[$i]['startint'];
            $si = $i;
        }
        else
        {
            $i++;
            continue;
        }

        if ($i === ($ec-1))
        {
            $oldorder_used[$si] = true;
            $neworder[$ei] = $days_events[$si];
            $ei++;
            $i = 0;
        }
        $i++;
        $allordered = combinebooleans($oldorder_used);
    }
}

//takes an array of booleans and combines them
function combinebooleans($arr_bools)
{
    //if not an array of booleans
    if (!is_array($arr_bools))
    {
        //if not a boolean
        if (!is_bool($arr_bools)) 
        { 
            return false; 
        }
        //if it is a boolean then lets return it
        else 
        { 
            return $arr_bools; 
        }
    }
    else
    {
        //variable to hold combined booleans
        $combined;

        //cycle through the array of booleans and 
        foreach ($arr_bools as $curb) 
        { 
            $combined = $combined | $curb; 
        }
        return $combined;
    }
}
  • 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-24T11:12:35+00:00Added an answer on May 24, 2026 at 11:12 am

    If you store your events in SQL DATABASE the best way to sort it is using ORDER BY

    If you have to sort it on php you probably can use usort:

    usort($array,function($eventA,$eventB)){
        //your own logic *
        return $comparisonResult;
    });
    

    * this function should return

    • -1 or other value less than 0 if $eventA should be before $eventB
    • 1 or other value less greater 0 if $eventA should be after $eventB
    • 0 overwise
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I believe this code may require more effort to comprehend than average, so I'm
The problem I see with this code is that although it is working, some
I have a block of code that runs within a TransactionScope and within this
This is an example of my jQuery code that I use in a function
We have the below code (partial code) that is used as part of a
I believe this question might have been previously attempted in 2006 on a different
I believe this question applies to any of the For Html helpers, but my
I believe this questions has been asked in some or the other way but
I believe this question applies equally well to C# as to Java, because both
I believe this is a beginner's CSS question. I am utilizing the method described

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.