[ create a new paste ] login | about

Link: http://codepad.org/wByv6Gz3    [ raw code | output | fork ]

PHP, pasted on Jul 10:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
	$id = 20;
	
	$imagePaths = array(
		"uploads/8/thumbs/8470177001370850253.png",
		"uploads/10/thumbs/967693821370850253.png",
		"uploads/9/thumbs/8470177001370850253.png",
		"uploads/11/thumbs/967693821370850253.png"
	);

	foreach ($imagePaths as $imagePath) {
		$newImagePath = preg_replace("#^uploads/[0-9]+/#", "uploads/" . $id . "/", $imagePath);
		var_dump($newImagePath);
	}
?>


Output:
1
2
3
4
string(41) "uploads/20/thumbs/8470177001370850253.png"
string(40) "uploads/20/thumbs/967693821370850253.png"
string(41) "uploads/20/thumbs/8470177001370850253.png"
string(40) "uploads/20/thumbs/967693821370850253.png"


Create a new paste based on this one


Comments: