Well, then I have a few questions, no regular, see how I solve.
1. Clears all tags in html, leaving only hyperlinks.
I use Strip_tags.
Strip_tags ($data, $tags)
$data is a string, $tags is a reserved label.
Strip_tags ($data, ' <a> '). Finished? Yes, it's that simple.
If I still want to keep ')
2. Intercepts the first match of a string from $STR1 to $str2 in the $str.
function Str_cut ($str, $start, $end) {//Remove first match, most efficient
$content = Strstr ($str, $start);
$content = substr ($content, strlen ($start), Strpos ($content, $end)-strlen ($start));
return $content;
}
3. Intercepts all matches of the string from $STR1 to $str2 in the $str.
function My_ca ($content, $start, $end) {//Remove all matches, do not include 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: You just want to sum up more, do not have regular, with PHP functions you can solve most of the problems.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service