Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.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 尝试使用curl获取调用内容中特定字符串后的数字_Php_Regex_Curl - Fatal编程技术网

Php 尝试使用curl获取调用内容中特定字符串后的数字

Php 尝试使用curl获取调用内容中特定字符串后的数字,php,regex,curl,Php,Regex,Curl,我使用CURL从表单提交中获取信息。然后,我将获取返回的数据字符串,搜索单词“Error”,并根据是否找到该字符串重定向错误并将其记录到txt文件中。一切正常,除了我需要得到字符串中的错误号。为了做到这一点,我试图找到“错误”这个词,然后抓住它后面的数字。但是,由于没有打印错误号,因此出现了一些问题。当我试图输出使用的pregmatch的结果时,我只得到NULL。我的代码如下 $Rec_Data = curl_exec($ch); ob_start(); header("Content-Ty

我使用CURL从表单提交中获取信息。然后,我将获取返回的数据字符串,搜索单词“Error”,并根据是否找到该字符串重定向错误并将其记录到txt文件中。一切正常,除了我需要得到字符串中的错误号。为了做到这一点,我试图找到“错误”这个词,然后抓住它后面的数字。但是,由于没有打印错误号,因此出现了一些问题。当我试图输出使用的pregmatch的结果时,我只得到NULL。我的代码如下

$Rec_Data = curl_exec($ch);

ob_start();
 header("Content-Type: text/html");
$Temp_Output = $Rec_Data;

if(strpos($Temp_Output,"Error")>=0){

   preg_match("/Error (\d+)/", $Temp_Output, $error);
   var_dump ($error[1]); //prints NULL and when printing $error it is an empty array.

}



}

$error[0]的值是多少?请给出一个输出字符串示例,其中包含要提取的数字…$error[0]也给出NULL。对于输出字符串,我想要的是单词Error后面的任何数字。因此,如果发现错误2,那么我想打印出错误2。