Jump to content

[SOLVED] Parse filename into bits...


aximbigfan

Recommended Posts

I created a PHP registry system, that emulates the Windows registry. Oen thign is, that the entries are storedin files, and the file names are like this:

<DIR>#<KEYNAME>.PRK

 

What I want to do, is parse these filenames into  array so that I have...

* The <DIR>

* The <Keyname>

 

How can I do this? The "#" separates the 2, and the filenames are URLencoded. The file extension also needs to be ignored.

 

Chris

Link to comment
https://forums.phpfreaks.com/topic/101294-solved-parse-filename-into-bits/
Share on other sites

$f1 = "dir1#key1.PRK"

//this will create an array--the last element will be the filename with the extension
//all other elements will be the folder names preceeding the filename.
$f2 = explode("#",$f1);

$filename = $f2[count($f2)-1];

$filename_noextension = explode(".", $filename);
$filename_noextension = $filename_noextension[0];

 

For info on these functions:

 

www.php.net/explode

www.php.net/count

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.