- preg_replace_callback: documentation ( source)
- base64_encode: documentation ( source)
<?php
$description = '<img src="http://web1.cz/obrazek.jpg">';
$description = preg_replace_callback('#<img(.*)src="(.*)"(.*)>#i', function($matches) {
return '<img'.$matches[1].'src="img/'.base64_encode($matches[2]).'"'.$matches[3].'>';
}, $description);
echo $description;