Rz Rasel Rz Rasel - 3 months ago 18
MySQL Question

Format or change MySql database data to realpath using preg_match or preg_replace in PHP

I am storing HTML data in MySQL database for some reason. how to get all image,css and jss file src from MySQL data and change it to realpath.
Like to

Same as to

And to

Using preg_match or preg_replace in PHP


Try to run this regex


Using preg_replace it will be something like this:

preg_replace('/(?:src|href)="(.*?)"/g', 'http:localhost/$1', 'Your field in database');

But test it not in production code, but in your local testing environment as I didn't test it.