0

次のコードを使用して、TXT ファイルに基づいて n 個のディレクトリを作成しようとしています。

<?php

$file = new SPLFileObject('/Applications/MAMP/htdocs/artists_report/2014/artists.txt');
foreach ($file as $line) {
    mkdir($line);
}

?>

私が期待しているのは、artists.txt <- $line にある各行に基づいて mkdir が namefolder を割り当てることですが、ディレクトリは名前なしで作成され、mkdir が $line を文字列として使用しない理由がわかりません。

何か案は?

4

2 に答える 2

0
<?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);
}

?>
于 2014-07-23T19:39:45.303 に答える