Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.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
有人能解释这4行php代码吗?我太糊涂了_Php_Preg Match All - Fatal编程技术网

有人能解释这4行php代码吗?我太糊涂了

有人能解释这4行php代码吗?我太糊涂了,php,preg-match-all,Php,Preg Match All,代码- $res=$this->post(“http://address.mail.yahoo.com/?_src=&VPC=print“,$post_元素); $emailA=array(); $bulk=array(); $res=str_replace(数组('','',PHP_EOL,'\n',“\r\n”),数组('','','',''),$res); preg#U match#U all(“\\\(.+)\(.+)\\\\\(.+)\\\\\(.+)\\\\\\(.+)\\\\\\\

代码-

$res=$this->post(“http://address.mail.yahoo.com/?_src=&VPC=print“,$post_元素);
$emailA=array();
$bulk=array();
$res=str_replace(数组('','',PHP_EOL,'\n',“\r\n”),数组('','','',''),$res);
preg#U match#U all(“\\\(.+)\(.+)\\\\\(.+)\\\\\(.+)\\\\\\(.+)\\\\\\\\\\\\\\(.U+)\\\\(.U”),$res$bulk);

$post_element
是一个数组,我主要使用
str_replace
preg_replace_all
函数行

在代码str_replace删除空格字符和preg_match_all通过正则表达式匹配html中的一些值,代码中没有preg_replace_all

$res=$this->post("http://address.mail.yahoo.com/?_src=&VPC=print",$post_elements);
    $emailA=array();
    $bulk=array();
    $res=str_replace(array('  ','   ',PHP_EOL,"\n","\r\n"),array('','','','',''),$res);
    preg_match_all("#\<tr class\=\"phead\"\>\<td colspan\=\"2\"\>(.+)\<\/tr\>(.+)\<div class\=\"first\"\>\<\/div\>\<div\>\<\/div\>(.+)\<\/div\>#U",$res,$bulk);
表示:将第一个数组中的字符串替换为第二个数组中的值,例如,将两个空格变为零,将三个空格变为零,将平台相关换行符变为零,将换行符变为零,将回车后的换行符变为零

$res = str_replace(
    array('  ','   ',PHP_EOL,"\n","\r\n"),
    array('','','','',''),
    $res);
preg\U match\U all(“\\\(.+)\(.+)\\\\\(.+)\\\\\(.+)\\\\\\\\\\\\(.+)\\\\\\\\\\\\\\\\\(.U”),$res$bulk);
意味着开发人员不知道不应该用正则表达式解析HTML

preg_match_all("#\<tr class\=\"phead\"\>\<td colspan\=\"2\"\>(.+)\<\/tr\>(.+)\<div class\=\"first\"\>\<\/div\>\<div\>\<\/div\>(.+)\<\/div\>#U",$res,$bulk);
->将数据发布到
http://address.mail.yahoo.com/?_src=&VPC=print
并获取响应,分配给$res

$res=$this->post("http://address.mail.yahoo.com/?_src=&VPC=print",$post_elements);
$emailA=array();
-->删除任何while空格、制表符空格、结束行

最后一个请参考这里

$res=str_replace(array('  ','   ',PHP_EOL,"\n","\r\n"),array('','','','',''),$res);