You could accomplish the same thing with the function
$variable = strtolower("$variable");
I think.
Mark Fleming wrote:
Hello,
I'm trying to use the following code to change the case of a file extension from JPG to jpg :
<?php
$search = "JPG";
$replace = "jpg";
$dirPath = opendir("images/test/");
while ($file = readdir($dirPath)) {
if ($file != "." && $file != "..") {
echo "$file";
$newfile = preg_replace ($search, $replace, $file);
echo "$newfile";
}
}
?>
When I run it, here is the output :
thm_DCP_2556.JPG
Warning: Delimiter must not be alphanumeric or backslash in rename.php3 on line 10
thm_DCP_2556.JPG is the file that preg_replace is trying to do its job on.
Any idea why this doesn't work? Is there a better way to do this? Thanks!