RE: [PHP-DEV] Parsing File Names
| From: | Chris Newbill | Date: | Thu, 28 Feb 2002 23:46:30 +0000 |
| Subject: | RE: [PHP-DEV] Parsing File Names | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-80532@lists.php.net to get a copy of this message | ||
This is really the wrong list for this. PHP-DEV is about developing
PHP, not developing WITH PHP. BUT since I like your username 'phpmonkey'
here's how ya'd do it. (untested of course, but the general idea) :)
<?php
$handle=opendir('/path/to/files');
while (false !== ($file = readdir($handle))) {
if (preg_match("/(.*) - (.*).mp3/i", $file, $matches)) {
$artist = $matches[1];
$song = $matches[2];
// insert into db
}
}
?>
-Chris
-----Original Message-----
From: Jason Dubya [mailto:phpmonkey@attbi.com]
Sent: Thursday, February 28, 2002 4:34 PM
To: php-dev@lists.php.net
Subject: [PHP-DEV] Parsing File Names
I am trying to create a script that will crawl through a directory, take
each file name, and parse it to get information from the filename. This
is going to be used to place artists and song names into a database.
The filenames are all in the following format: artist - songname.mp3
Is there an easy way to parse that to create two variables: $artist &
$songname?
-- Jason Dubya
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php