I'm trying to rename some jpegs in a single directory. The code half works in that they are renamed with the correct filenames but for some reason the new filenames are surrounded with double quotes which makes them inaccessible from my web pages.
Any help appreciated!
$i = 10000;
foreach ($imgArray as $v) {
$html_file_name = basename($v).PHP_EOL;
$html_file_name = str_replace(range(0,9),'', $html_file_name);
$path = pathinfo($v, PATHINFO_DIRNAME);
$target = ++$i . $html_file_name;
rename ($v, $path . '/' . $target);
}
OK so here's the var_dump($imgArray):
array(3) { [0]=> string(47) "../img/gallery/this-is-the-first/10002-vddf.jpg" [1]=> string(51) "../img/gallery/this-is-the-first/10001-vfdssddf.jpg" [2]=> string(50) "../img/gallery/this-is-the-first/10003-vddsvsf.jpg" }
Serialized:
a:3:{i:0;s:47:"../img/gallery/this-is-the-first/10002-vddf.jpg";i:1;s:51:"../img/gallery/this-is-the-first/10001-vfdssddf.jpg";i:2;s:50:"../img/gallery/this-is-the-first/10003-vddsvsf.jpg";}