file_array_gen.php:
Code: Select all
<?php
if(($dhandle = opendir('C:\\grower')) !== false) {
$file_array= array();
while(($file=readdir($dhandle))!== false){
if($file !== '.' && $file !== '..'){
$file_array[] = $file;}
}
shuffle($file_array);
$file_out = '<?php \r\n \$file_array = array(); \r\n';
for($i=0; $i <= count($file_array) - 1; $i++){
$file_exp = explode('.', $file_array[$i]);
$ext = array_pop($file_exp);
if($ext == 'pdf'){
$file_out .= '\$file_array[] = "'.$file_array[$i].'";\r\n';
}
}
$file_out .= '\r\n ?>';
if(($fhandle = file_put_contents('C:\\xampp\\htdocs\\file_array.php', $file_out)) == false) {
die('Unable to open file.'); exit;}
closedir($dhandle);
} else { die('Unable to open directory.'); exit;}
exit;
?>Code: Select all
<?php \r\n \$file_array = array(); \r\n\$file_array[] = "measures_expansion.pdf";\r\n\$file_array[] = "Measures_Formula.pdf";\r\n\$file_array[] = "measures.pdf";\r\n\$file_array[] = "Measures_Doc.pdf";\r\n\r\n ?>*EDIT*
Also is there a way to output to the file so each $file_array[] statement is on a new line to ease readability?