php regular please php regular go away

WBOY
Release: 2016-07-29 08:37:24
Original
940 people have browsed it

Okay, let me ask a few questions without using regular expressions and see how I solve them.
1. Clear all tags in HTML, leaving only hyperlinks.
I use strip_tags.
                                                                                                                                                        out   out out out out of out out out out out of ’ s to  to  off-to-under-be-reserve to.
                                                                        strip_tags($data,''). Finished? Yes, it's that simple. If I still want to retain & lt; img & gt;, then strip_tags ($ data, '& lt; a & gt; & lt; IMG & GT;')
2. Test the first match of the first match from $ Str1 to $ Str2. . On Function Str_cut ($ Str, $ Start, $ END) {// Take out the first match, the highest efficiency
$ Content = Strstr ($ Str, $ Start); ), strpos( $content, $end ) - strlen( $start ) );
                    return  $content;
function my_Ca($content,$start,$end){//Get all matches, excluding the start and end strings
$m = explode($start,$content);
$a = array();
$ sum = count($m);
for( $i = 1;$i < $sum;$i++ )
{
$my = explode($end,$m[$i]);
$a[] = $my[0];
unset($my);
return $a;
}
Summary: As long as you think more and summarize, without using regular rules, you can solve most problems using the functions that come with PHP.
The above introduces the PHP regularity. Please PHP regularity go away, including the PHP regularity content. I hope it will be helpful to friends who are interested in PHP tutorials.


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!