Home  >  Article  >  Backend Development  >  php regular please php regular go away

php regular please php regular go away

WBOY
WBOYOriginal
2016-07-29 08:37:24979browse

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.