I'm trying to create n directories based on a TXT file using this code:
<?php
$file = new SPLFileObject('/Applications/MAMP/htdocs/artists_report/2014/artists.txt');
foreach ($file as $line) {
mkdir($line);
}
?>
What I expect is mkdir assigning a namefolder based on each line I've got in artists.txt <- $line, but the directories are created without names and I can't understand why mkdir is not taking $line as a string.
Any ideas?
Use file
instead of SPLFileObject
$file = file('/Applications/MAMP/htdocs/artists_report/2014/artists.txt');
foreach ($file as $line) {
mkdir($line);
}
This assumes that each line in artists.txt
is a full path name