Preg_match用于机器人

时间:2017-03-17 01:48:17

标签: php preg-match preg-match-all

我有一个每日比赛的机器人。但我无法弄清楚它将如何完全替换标签, 例如,我有这样的数据;

$connect = sanitize_output(connect("h****"));

preg_match_all('@{"id":"(.*?)","title":"(.*?)","type":"(.*?)","flag":"(.*?)","time":"(.*?)","time":"(.*?)","live":"(.*?)"}@si',$connect,$football_t);   

$id=$football_t[0][0];
$title=$football_t[0][1];

代码:

{{1}}

VS

有了这个用途,我无法选择数据, 我想和foreach一起做表,但我无法弄清楚它是怎么回事。

1 个答案:

答案 0 :(得分:1)

使用json_decode()解析JSON字符串,而不是正则表达式。

$data = json_decode($connect);
$id = $data->id;
$title = $data->title;

您也不应该清理JSON,这可能会阻止json_decode()正确解析它。

相关问题