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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:35:36+00:00 2026-05-29T15:35:36+00:00

I make a curl request to a server which returns javascript and I need

  • 0

I make a curl request to a server which returns javascript and I need to get each of the addNewEvent functions returned into a PHP array. So I figured I would use preg_match_all.

Unfortunately regex is not my strong point and I keep getting it wrong. Could someone please help me out with this?

I have this so far:

'/addNewEvent\(\{(.*)\}\);/s'

This is a snippet from the javascript containing the functions I need. The rest of the javascript does contain if statements with braces:

addNewEvent({id:2, type:1,
start: new Date(2012,02-1,10,09,00),
end:new Date(2012,02-1,10,10,00), 
startRounded:new Date(2012,1,10,9,0),
endRounded:new Date(2012,1,10,10,0),
desc:"test", allDay:0, recurring:0, reminder:0,
comment:"this is a tes\\\'st\\\"",
labelColor:\'#FF9281\', numOverlaps:0, overlapNumber:0});
addNewEvent({id:3, type:1,
start: new Date(2012,02-1,10,09,00),
end:new Date(2012,02-1,10,10,00), 
startRounded:new Date(2012,1,10,9,0),
endRounded:new Date(2012,1,10,10,0),
desc:"test 2", allDay:0, recurring:0, reminder:0,
comment:"",
labelColor:\'#849CE7\', numOverlaps:0, overlapNumber:0});

Thanks in advance.

Edit 13:23

Ideally I would like to have returned an array containing the JSON objects from inside the javascript function calls:

array(
    [0] => '{id:2, type:1,
        start: new Date(2012,02-1,10,09,00),
        end:new Date(2012,02-1,10,10,00), 
        startRounded:new Date(2012,1,10,9,0),
        endRounded:new Date(2012,1,10,10,0),
        desc:"test", allDay:0, recurring:0, reminder:0,
        comment:"this is a tes\\\'st\\\"",
        labelColor:\'#FF9281\', numOverlaps:0, overlapNumber:0}',
    [1] => '{id:3, type:1,
        start: new Date(2012,02-1,10,09,00),
        end:new Date(2012,02-1,10,10,00), 
        startRounded:new Date(2012,1,10,9,0),
        endRounded:new Date(2012,1,10,10,0),
        desc:"test 2", allDay:0, recurring:0, reminder:0,
        comment:"",
        labelColor:\'#849CE7\', numOverlaps:0, overlapNumber:0}'
);
  • 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-29T15:35:37+00:00Added an answer on May 29, 2026 at 3:35 pm

    Here is a full test (I’ve replaced some single quotes by double quotes to use heredoc syntax) :

    $pattern='/addNewEvent\(\{(.*)\}\);/sU';
    
    $subject='addNewEvent({id:2, type:1,
    start: new Date(2012,02-1,10,09,00),
    end:new Date(2012,02-1,10,10,00), 
    startRounded:new Date(2012,1,10,9,0),
    endRounded:new Date(2012,1,10,10,0),
    desc:"test", allDay:0, recurring:0, reminder:0,
    comment:"this is a tes\\\"st\\\"",
    labelColor:\"#FF9281\", numOverlaps:0, overlapNumber:0});
    addNewEvent({id:3, type:1,
    start: new Date(2012,02-1,10,09,00),
    end:new Date(2012,02-1,10,10,00), 
    startRounded:new Date(2012,1,10,9,0),
    endRounded:new Date(2012,1,10,10,0),
    desc:"test 2", allDay:0, recurring:0, reminder:0,
    comment:"",
    labelColor:\"#849CE7\", numOverlaps:0, overlapNumber:0});';
    
    print '<pre>';
    if(preg_match_all($pattern,$subject,$matches)){
        print_r($matches[1]);
    }    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when I make a GET request with curl to a remote web server I
I need to make a cURL request to a https URL, but I have
I'm using curl to make php send an http request to some website somewhere
I try to make a post request with php and curl. Here is my
I need to make a POST request via cURL from the command line. Data
I have a PHP CURL request to an HTTPS site which takes a JSON
I am unable to make a php curl request with port number , without
How can I make a simple CURL request to that Flickr API that does
I'd like to make a cURL request that accepts a gzip'ed page. I would
I need to make an HTTP POST request from outside the browser, but 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.