Hi,
I'm assuming that this is going to need to use something like ereg_replace or similar but as I'm not too familiar with regular expressions....Help!
Basically, I need to replace the src of all images in a file with a unique identifier (different for each unique image).
So in english... I want to say - replace everything between "<img" and the following occurance of ">" with my own incremental identifier. So we have to replace one image at a time.
At the moment I'm blagging it a bit with the following code....
$n_images = substr_count($text,"<img");
$starting_point=0;
for($i=0;$i<$n_images;$i++){
$stringstart = strpos($text,"<img",$starting_point);
$stringend = strpos($text,">",$stringstart);
$string_length = ($stringend+1)-$stringstart;
$string = substr($text,$stringstart,$string_length);
$text = str_replace($string,"<img src='cid:000".$i."'>",$text);
$starting_point = ($stringend+1);
$image_array[] = "cid:000".$i;
}
The problem is that when the <img> tag gets over about 70 characters in length it all goes wrong!
If anyone can help I would be most grateful