Ask php regular expression to go away. Okay, so I have a few questions and don't need regular expressions. let's see how I solve them. 1. clear all tags in HTML and only keep the hyperlink. I use strip_tags. Strip_tags ($ data, $ tags) $ data is good, so I have a few questions and don't need regular expressions. how can I solve them.
1. clear all tags in HTML and only keep the hyperlink.
I use strip_tags.
Strip_tags ($ data, $ tags)
$ Data is a string and $ tags is a reserved tag.
Strip_tags ($ data. Finished? Yes, that's simple.
If I want to keep it, strip_tags ($ data ,'')
2. intercept the first match between $ str1 and $ str2 in $ str.
Function str_cut ($ str, $ start, $ end) {// retrieve the first match with the highest efficiency
$ Content = strstr ($ str, $ start );
$ Content = substr ($ content, strlen ($ start), strpos ($ content, $ end)-strlen ($ start ));
Return $ content;
}
3. intercept all matching strings from $ str1 to $ str2 in $ str.
Function my_Ca ($ content, $ start, $ end) {// retrieve 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 $;
}
Conclusion: you only need to think more about it and do not need regular expressions. you can solve most of the problems with the built-in functions of PHP.
Bytes. 1. clear all tags in HTML and only keep the hyperlink. I use strip_tags. Strip_tags ($ data, $ tags) $ data is...