Sunday 28 April 2019

html - Writing regular expression in PHP to wrap with




I want to make it so that any occurance of an image gets wrapped with a link to the image source



How can I write a pattern, in PHP so that I can find these variations, which are scattered throughout text coming from the database:



blah blah blah
blah blah blah



In all cases, I want them to appear within an link.


Answer



preg_replace("{}ims", '', $str)



handles all non-practical cases



alt text


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...