Hi I've this code <a href="http://google.com"><img border="0" src="http://www.google.co.in/intl/en_com/images/logo_plain.png"> Code (markup): I want to get the src="" part of the above line and then update the entire code with <a rel="lightbox" href="http://google.com"><img border="0" src="http://www.google.co.in/intl/en_com/images/logo_plain.png"> Code (markup): How this can be done using php ?
Not sure if this is what your looking for ? $find_src = preg_replace('#src="(.*?)"#','src="replace with this new image"',$find_src); echo $find_src; PHP: Anything between the two ## will be replaced with src="replace with this new image"
No. This is not what I actually want. I just want to add to the <a href> tag immediate after the <a. But note that , I need to add this line only if the <a tag is for <img> That is <a href="url> <img src="pic.png"></a> - > I need to add <a href="url> Some text </a> -- > I don't need to add
Not really I want to add that line to <a> tag, not <img > Like <a rel="lightbox" href="url> <img src="pic.png"></a> - > I need to add Code (markup):
What effect would it have if the rel="lightbox" was added to normal text links ? $find_href = preg_replace('#<a href="#','<a rel="lightbox href="',$find_href); echo $find_href; PHP:
Download your database and do a find & replace, then star fresh writing skills. Otherwise its impossible to archive what you want.
maybe this $linkWithimg = '<a href="url"><img src="pic.png"></a>'; if (preg_match("/<img src=/i", $linkWithimg)) { $final = str_ireplace("<a href=", '<a rel="lightbox" href=', $linkWithimg); echo $final; } PHP: