从PHP字符串中提取特定值
我正在尝试学习动态分页的tweeter结果的max_id 搜索元数据如下所示:从PHP字符串中提取特定值,php,string,twitter,extract,Php,String,Twitter,Extract,我正在尝试学习动态分页的tweeter结果的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",
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\u id
转换为php值,这将非常方便
因此,是否有方法提取数字326811400389406719
(以及类似于中的任何其他数字)?max_id=326811400389406719&q=%23helloworld&count=10&include_entities=1
字符串
谢谢!正则表达式
$string = '?max_id=326811400389406719&q=%23helloworld&count=10&include_entities=1';
preg_match('/max_id=(\d+)/', $string, $matches);
$max_id = $matches[1];
正则表达式
$string = '?max_id=326811400389406719&q=%23helloworld&count=10&include_entities=1';
preg_match('/max_id=(\d+)/', $string, $matches);
$max_id = $matches[1];
可能有帮助您可能会帮助您$str=substr(“?max_id=32681140389406719&q=%23helloworld&count=10&include_entities=1”,1);//删除第一个”?“$str=substr(?max_id=3268111400389406719&q=%23helloworld&count=10&include_entities=1”,1)//删除第一个“?”