Reputation:
I have tried for it. But I could not do that, Here is my code
$p = '|<a [^>]*href="http://<some url>[^"]*"[^>]*>.*</a>|iU';
preg_replace($p, '$1', $a);
From above code I get all the link from that text, except the specific url. I want to get all the data in between link tag. Thats all.
Here is the link
<a href="http://<some url>"> <img src="Some url" alt="DZJarAP" width="213" height="300"></a>
I want it to be like
<img src="http://<some url>" alt="DZJarAP" width="213" height="300">
It may be any tag like img,p,div
Please help me out. Your answer are highly appreciable
Upvotes: 3
Views: 115
Reputation: 21489
You can do this work using preg_match
like this
preg_match("/^(<.*?>)(.*)(<.*?>)$/", $HTML, $matchs);
$imgsTag = $matchs[2];
It return every tag in <a>
.
Upvotes: 1
Reputation: 145
This should help, if I got the correct question:
$p = '|<a href="(.*)">(.*").*(".*)</a>|iU';
preg_replace($p, '$2$1$3', $a);
It will result in:
<img src="http://onlinegamesocean.com" alt="DZJarAP" width="213" height="300">
That only works if your tag in between has a link starting and ending with quotation marks. The link to replace must be the first quoted parameter.
What a <p>
and <div>
tag have to do with a link is not clear from your question.
Upvotes: 0