Reputation: 53
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?
Upvotes: 0
Views: 804
Reputation: 3369
<?php
$filedirectory = '/Applications/MAMP/htdocs/artists_report/2014/';
//read from your file using SPLFileObject
...some code that is setting $line with a value but converts back to a string...
//i would make $line an array or something so you can simply do:
foreach ($line AS $artist) {
mkdir($filedirectory.$artist);
}
?>
Upvotes: 0