I have a bit of PHP code for searching the first 'column' of a CSV file for a filename, and if it's found it 'removes' it into a 'removed' folder.
There must be something wrong with my code because if (in_array
is not seeing a name in the array which is identical to $fileNoExtension
. I added the line at the bottom to check, and I get echo'd back to me "[ImportantFile] apparantly is not the same as [ImportantFile]???
"
I've taken the code out which gets fileNoExtension
from $thisFileWithExtension
just so it's not in the way.
foreach ($fileArray as $FileWithExtension) {
if (file_exists('PHP/ManualRemove.csv')) {
$csvManualDemos = fopen("PHP/ManualRemove.csv", "r");
while ($csvRows = fgetcsv($csvManualRemove)) {
if (in_array($fileNoExtension, $csvRows)) {
echo "Found on manual remove list. Removed.";
rename("$fileWithExtension", "Removed/$fileWithExtension");
continue;
} else
echo "\n [$fileNoExtension] apparantly is not the same as [$csvRows[0]]???\n";
}
}
}
I'm sure i've got some code wrong somewhere but I can't work it out! Many thanks :D