I'm trying to parse site data using PHP + curl. And that's what I saw in the debug window in chrome: http://i.stack.imgur.com/xcJpL.png
Here is a server response below. How to parse it to PHP object?
Arr = new Array();
Arr[Arr.length] = new MeetingDetails();
Arr[Arr.length - 1].mode = 2;
Arr[Arr.length - 1].details = replaceLineBreakToHTML('');
Arr[Arr.length - 1].meetingTime = CreateNewDateFromMiliInUTC(1432374300000);
var informationArr=new Array();
Arr[Arr.length - 1].cfInformationArr=informationArr;
Arr[Arr.length - 1].attendeeArray = new Array();
Arr[Arr.length - 1].attendeeArray[0] = new Array();
Arr[Arr.length - 1].attendeeArray[0][0] = htmlDecodeText('Sue',true);
Arr[Arr.length - 1].attendeeArray[0][1] = htmlDecodeTextWOlt('suew');
Arr[Arr.length] = new MeetingDetails();
Arr[Arr.length - 1].mode = 2;
Arr[Arr.length - 1].details = replaceLineBreakToHTML('');
Arr[Arr.length - 1].meetingTime = CreateNewDateFromMiliInUTC(1431769500000);
var informationArr=new Array();
Arr[Arr.length - 1].cfInformationArr=informationArr;
Arr[Arr.length - 1].attendeeArray = new Array();
Arr[Arr.length - 1].attendeeArray[0] = new Array();
Arr[Arr.length - 1].attendeeArray[0][0] = htmlDecodeText('Tara ',true);
Arr[Arr.length - 1].attendeeArray[0][1] = htmlDecodeTextWOlt('suew');
Looks like a code, but how to make a PHP object from this?
Thanks for any ideas.
Solution:
<?php
$data = file_get_contents('scheduleonce.txt');
$data = explode("
", $data);
$arr = array();
$i = - 1;
foreach ($data as $string) {
preg_match_all("#.title = htmlDecodeText\('(.*?)',true\);#i", $string, $matches);
if (isset($matches[1][0])) {
$i++;
$arr[$i]['title'] = $matches[1][0];
}
preg_match_all("#.status = (.*?);#i", $string, $matches);
if (isset($matches[1][0])) $arr[$i]['status'] = $matches[1][0];
}
print_r($arr);
You can do one thing, Use json encode and decode fujction.
First push array to json encode then push encode to decode.
$varObj = jason_decode( json_encode($arr)) ;