Thanks Ben, really appreciate your help
I tried your code and it's almost working. I'm running PHP 4

so I had to use a couple of alternatives for the case-sensitive functions...
This is the result of the code on an image:
Code: Select all
<img width="300" hspace="5" height="225" align="right" src="src="http://www.domain.com"src="src="http://www.domain.com"uploads/images/Sunset.jpg"http://www.domain.com" alt="" />
Here is the result on the second image from the array... for some reason it's a little better...:
Code: Select all
<img width="100" height="75" src="src="http://www.domain.com"uploads/images/Sunset.jpg" alt="" />
Here is the print_r() of $matches:
Code: Select all
Array
(
[0] => Array
(
[0] => src="uploads/images/Blue hills.jpg"
[1] => src="uploads/images/Sunset.jpg"
)
[1] => Array
(
[0] => src="
[1] => src="
)
[2] => Array
(
[0] => uploads/images/Blue hills.jpg
[1] => uploads/images/Sunset.jpg
)
)
Array
(
[0] => Array
(
[0] => src="uploads/images/Blue hills.jpg"
)
[1] => Array
(
[0] => src="
)
[2] => Array
(
[0] => uploads/images/Blue hills.jpg
)
)
Here is the print_r() of $match in the foreach() function
Code: Select all
Array
(
[0] => src="uploads/images/Blue hills.jpg"
[1] => src="uploads/images/Sunset.jpg"
)
Array
(
[0] => src="
[1] => src="
)
Array
(
[0] => uploads/images/Blue hills.jpg
[1] => uploads/images/Sunset.jpg
)
Array
(
[0] => src="uploads/images/Blue hills.jpg"
)
Array
(
[0] => src="
)
Array
(
[0] => uploads/images/Blue hills.jpg
)
And here is the final code, I had to had some back slashes to the preg_match_all() function but I think that's all I fiddled with...
Code: Select all
if (preg_match_all("#(src=\")([^\"]*)\"#i", $content, $matches, PREG_PATTERN_ORDER)) {
foreach ($matches as $match) {
if (stripos($match[2],'http') === FALSE) {
$src = 'src="' . $match[1] . $websiteurl . $match[2] . '"';
$content = str_ireplace($match[0], $src, $content);
}
}
}