0

代码-

$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);

$post_element是一个数组,我主要是consern ablutstr_replacepreg_replace_allfunction line

4

3 回答 3

2
$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);

意味着开发人员不知道不应使用 Regex 解析 HTML。

于 2010-08-10T11:34:16.663 回答
0

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

于 2010-08-10T11:33:48.080 回答
0
$res=$this->post("http://address.mail.yahoo.com/?_src=&VPC=print",$post_elements);
$emailA=array();

-> 发布数据http://address.mail.yahoo.com/?_src=&VPC=print并获取响应,分配给 $res

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

--> 删除任何 while-space、tab-space、end-line ...

并在此处参考最后一个 http://php.net/manual/en/function.preg-match-all.php

于 2010-08-10T11:37:33.347 回答