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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:12:19+00:00 2026-05-31T00:12:19+00:00

I have an edit script which retrieves calendar events and lets the user edit

  • 0

I have an edit script which retrieves calendar events and lets the user edit these events.

There are 3 types of events; single occurring, daily recurring, and weekly recurring.

The edit script handles all 3 types (where the format of the data is slightly different for each).

Regarding the 2 types of recurring events, there is no way for me to tell which one is being processed until I use preg_match. I have 2 preg_match functions, the first is for daily recurring events, and the second is for weekly recurring events.

My code first passes the string which contains the event info into the daily preg_match function. If the variables are assigned then there is no problem.

If the variables however have not been assigned, I then pass the same string into the weekly preg_match function. This is where I get following error:

Notice: Undefined offset:

I will now show my code.

To begin with, the 2 types of string:

(Daily Recurring Event)
DTSTART;VALUE=DATE:20120306 DTEND;VALUE=DATE:20120307 RRULE:FREQ=DAILY;INTERVAL=3;UNTIL=20120331 

(Weekly Recurring Event)
DTSTART;VALUE=DATE:20120201 DTEND;VALUE=DATE:20120201 RRULE:FREQ=WEEKLY;BYDAY=Tu,Fr;UNTIL=20120331

The above strings are stored in the variable $eventtype

The code to process this:

recurrence_info_day($eventtype);
$recurrence_type = "daily";
if ($d = false){
    recurrence_info_weekly($eventtype);
    $recurrence_type = "weekly";
}

function recurrence_info_day($eventtype){
    global $eventstart, $eventend, $eventfrequency, $eventinterval, $eventuntil, $formstartdate, $formenddate, $xyz;
    $s = $eventtype;    
    preg_match(
      '/^DTSTART;VALUE=DATE:(\d+)\s+DTEND;VALUE=DATE:(\d+)\s+RRULE:FREQ=(\w+);INTERVAL=(\d+);UNTIL=(\d+)/',
      $s,
      $recinfod
    );
    $eventstart = $recinfod[1];
    $eventend = $recinfod[2];
    $eventfrequency = $recinfod[3];
    $eventinterval = $recinfod[4];
    $eventuntil = $recinfod[5];

    $formstartdate = substr($eventstart,4,2)."/".substr($eventstart, 6)."/".substr($eventstart,0,4);
    $formenddate = substr($eventuntil,4,2)."/".substr($eventuntil, 6)."/".substr($eventuntil,0,4);

    $d = true;
    if (!$eventstart){
         $d = false;
    }
}

//Weekly recurring events
function recurrence_info_weekly($eventtype){
    global $eventstart, $eventend, $eventfrequency, $eventdays, $eventuntil, $formstartdate, $formenddate;
    $s = $eventtype;
    preg_match(
        '/^DTSTART;VALUE=DATE:(\d+)\s+DTEND;VALUE=DATE:(\d+)\sRRULE:FREQ=(\w+);BYDAY= (\d+);UNTIL=(\d+)/',
        $s,
        $recinfow
    );
    $eventstart = $recinfow[1];
    $eventend = $recinfow[2];
    $eventfrequency = $recinfow[3];
    $eventdays = $recinfow[4];
    $eventuntil = $recinfow[5];

    $formstartdate = substr($eventstart,4,2)."/".substr($eventstart, 6)."/".substr($eventstart,0,4);
    $formenddate = substr($eventuntil,4,2)."/".substr($eventuntil, 6)."/".substr($eventuntil,0,4);
}

When I have a daily recurring event, this script works as it should.

From what I can tell, the problem is with the preg_match function for the weekly string – recurring_info_weekly()
I get undefined offset errors when I call this function alone, or as in the above code.
The recurring_info_day() function does work. It’s just the week function that gives the error.

Any help is appreciated, thank you 🙂

  • 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-31T00:12:20+00:00Added an answer on May 31, 2026 at 12:12 am

    I see a problem in your second pattern. You are checking for digits following BYDAY, but your example has alpha characters in that position. This would cause only 4 matches in the second pattern, and the undefined offset when you attempt to access [5].

    DTSTART;VALUE=DATE:20120201 DTEND;VALUE=DATE:20120201 RRULE:FREQ=WEEKLY;BYDAY=Tu,Fr;UNTIL=20120331
    
    /^DTSTART;VALUE=DATE:(\d+)\s+DTEND;VALUE=DATE:(\d+)\sRRULE:FREQ=(\w+);BYDAY=(\d+);UNTIL=(\d+)/
    //-------------------------------------------------------------------------^^^^^^^
    

    Instead you may try replacing that with [A-za-z,] to match alpha characters and the comma.

    /^DTSTART;VALUE=DATE:(\d+)\s+DTEND;VALUE=DATE:(\d+)\sRRULE:FREQ=(\w+);BYDAY=([A-za-z,]+);UNTIL=(\d+)/
    //---------------------------------------------------------------------------^^^^^^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often have to edit script files, the interpreter for which treats files that
i have to create a simple script which retrieves the mails from gmail account
I have written a little script which retrieves pictures and movies from my camera
i have a little script which fetches the likes and tweets count about a
I have PHP script which takes some file (FLV for example) and returns it
I have got script which generates some graphic and returns it as a result,
I have written a python script which read from a txt file and perform
I have a PHP script which reads from an xml file to generate a
I have a voting script which stores the post_id and the user_id in a
I have a script which can make each table row clickable (as a link),

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.