i need a script to get all the filenames from a directory into an array....
how do i do this...
thanks
-m
Have a look at the opendir function in the manual. Or if you are on a unix host do
$dirstr = shell_exec( 'ls' ); $dir = explode( '\n',$dirstr );
HalfaBee
That explode hasn't worked with me, have to have double quotes "" so \n is interpreted correctly
try
$dirstr = shell_exec( 'ls' ); $dir = explode( "\n",$dirstr );
instead of $dirstr = shell_exec( 'ls' ); $dir = explode( '\n',$dirstr );
Sorry 🙁
<?php $files = array(); if ($handle = opendir('/path/to/files')) { while (false !== ($file = readdir($handle))) { array_push($files,$file); } } print_r($files); ?>