Re: adding a comma between a list of file names

From: Date: Wed, 05 Mar 2003 22:52:32 +0000
Subject: Re: adding a comma between a list of file names
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-138388@lists.php.net to get a copy of this message
The simplest way would be to build an array of filenames then implode the array. $handle = opendir($emaildir); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $emailes[] =substr($file,0,strpos($file,'.')); } } closedir($handle); $emailes = implode(',', $emailes); - Kevin ----- Original Message ----- From: "Richard Kurth" <rdkurth@starband.net> To: "php-general" <php-general@lists.php.net> Sent: Wednesday, March 05, 2003 3:36 PM Subject: [PHP] adding a comma between a list of file names > The scrip below will list all the files in a directory and also strip off every > thing in the file name after a . > so if I have files named 1.txt 2.txt 324.txt 5.txt it gives me a list that > looks like this 123245. I need to add a , in between each of these file > names so they will look like 1,2,324,5 > For some reason I keep looking at this and for the life of me can't > figure out what I need to do. > > $handle = opendir($emaildir); > while (false !== ($file = readdir($handle))) { > if ($file != "." && $file != "..") { > $emailes .=substr($file,0,strpos($file,'.')); > } > } > closedir($handle); > > > > -- > Best regards, > Richard mailto:rdkurth@starband.net > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#138388) next »