I am having some issues with PHP preg_replace.
I have a url that contains a image-url with numbers added, e.g.:
The numbers at the end are always different.
To seperate the sting, I am using
$parts = explode(",", $url);
To figure out how many numbers there are, I am using:
$numbers = count($parts);
My problem is to replace the end of $url[0] with $parts (starting with parts[1] up to parts[$numbers-1])
Any idea what I need to change??
Here is my code:
for($i=1;$i<=10;$i++) {
$array[] = preg_replace('/\d+.jpg/',sprintf("%01d.jpg",$i),$url[0]);
}
<img src="<?php echo($array[0]); ?>"/>
<img src="<?php echo($array[1]); ?>"/>
<img src="<?php echo($array[2]); ?>"/>
<img src="<?php echo($array[3]); ?>"/>
<img src="<?php echo($array[4]); ?>"/>
<img src="<?php echo($array[5]); ?>"/>
<img src="<?php echo($array[6]); ?>"/>
<img src="<?php echo($array[7]); ?>"/>
<img src="<?php echo($array[8]); ?>"/>
<img src="<?php echo($array[9]); ?>"/>