Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从PHP字符串中提取特定值_Php_String_Twitter_Extract - Fatal编程技术网

从PHP字符串中提取特定值

从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",

我正在尝试学习动态分页的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",
  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)//删除第一个“?”