如何将其解析为PHP对象?

时间:2015-05-09 15:32:21

标签: php parsing

我尝试使用PHP + curl解析网站数据。这就是我在chrome中调试窗口中看到的内容:http://i.stack.imgur.com/xcJpL.png

以下是服务器响应。如何将其解析为PHP对象?

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');

看起来像代码,但是如何从中创建PHP对象?

感谢任何想法。

2 个答案:

答案 0 :(得分:0)

解决方案:

<?php
$data = file_get_contents('scheduleonce.txt');
$data = explode("\r\n", $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);

答案 1 :(得分:-1)

你可以做一件事,使用json编码和解码fujction。

首先将数组推送到json编码,然后将编码推送到解码。

$ varObj = jason_decode(json_encode($ arr));