我正在尝试学习动态分页的推特结果的max_id。
搜索元数据如下:
search_metadata: {
completed_in: 0.033,
max_id: 326811859678277600,
max_id_str: "326811859678277634",
next_results: "?max_id=326811400389406719&q=%23helloworld&count=10&include_entities=1",
query: "%23helloworld",
refresh_url: "?since_id=326811859678277634&q=%23helloworld&include_entities=1",
count: 10,
since_id: 0,
since_id_str: "0"
}我的脚本可以很方便地将下一个结果中的max_id转换为php值。
因此,有没有一种方法可以从?max_id=326811400389406719&q=%23helloworld&count=10&include_entities=1字符串中提取数字326811400389406719 (以及其他类似的数字?
谢谢!
发布于 2013-04-27 08:04:48
$str = "?max_id=326811400389406719&q=%23helloworld&count=10&include_entities=1"
parse_str($str, $output);
$max_id = $output['?max_id'];
//print_r($output);发布于 2013-04-27 07:50:49
正则表达式?
$string = '?max_id=326811400389406719&q=%23helloworld&count=10&include_entities=1';
preg_match('/max_id=(\d+)/', $string, $matches);
$max_id = $matches[1];https://stackoverflow.com/questions/16246776
复制相似问题