php获取指定位置内容
这款函数比较实用于数据采集,一般采集数据时会要指定一个区域的内容,这个代码就可以实例:
$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 ; }查看更多关于php获取指定位置内容 - php函数的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did30923