Hello, I have a folder called csv which resides on public_html. All the files are .csv files. How do I get all the file names into an array, without having the extension. Thanks
Use explode. Example: $file = "file.csv"; $exp = explode(".", $file); $array = array($exp[0]); Resource: http://www.w3schools.com/php/php_arrays.asp
*SIGH*, people are dumber for having read the responses so far. As a rule of thumb you can't trust explode since you don't know how many periods are in a filename since there's no real restriction on that anymore... and I have no clue what "thatabuts" is trying to do as that's just gibberish. The correct answer is PHP's pathinfo command. http://www.php.net/manual/en/function.pathinfo.php Preferably after a glob to actually pull the directory using a filter. http://php.net/manual/en/function.glob.php $fileList=glob('csv/*.csv'); foreach ($fileList as $fileName) { echo pathinfo($fileName,PATHINFO_FILENAME),'<br />'; } Code (markup): Note that pathinfo can be used to pull an array containing all the values, or you can pass different named constants to it to pull information like PATHINFO_EXTENSION, PATHINFO_DIRECTORY or even PATHINFO_BASENAME.