php获取指定位置内容
发布时间:2022-07-28 09:21:52 所属栏目:PHP教程 来源:互联网
导读:这款函数比较实用于数据采集,一般采集数据时会要指定一个区域的内容,这个代码就可以实例: $str=!-- fdaf-- --; echo strip_comments( $str ); function strip_comments($data) { $the_rest = $data; $result = ; while ($the_rest) { $start = strpos($the_r
|
这款函数比较实用于数据采集,一般采集数据时会要指定一个区域的内容,这个代码就可以实例: $str="<!-- fdaf-- -->"; echo strip_comments( $str ); function strip_comments($data) { $the_rest = $data; $result = ""; while ($the_rest) { $start = strpos($the_rest, "<!--"); if ($start === false) { $result .= $the_rest; break; } $result .= substr($the_rest, 0, $start); $end = strpos($the_rest, "-->", $start); if ($end === false) { break; } $the_rest = substr($the_rest, $end+3); } return $result; } (编辑:孝感站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

