note 73323 added to function.filetype
| From: | jchonlasithatyahoodotcom at osu1 dot php dot net | Date: | Sun, 18 Feb 2007 04:28:39 +0000 |
| Subject: | note 73323 added to function.filetype | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123528@lists.php.net to get a copy of this message | ||
Here is my function to get the filename information.
function get_filename_info($filepath)
{
$last_slash = strlen($filepath) - strlen(strrchr($filepath, "/"));
$path_name = ($last_slash === FALSE)?"":substr($filepath, 0, $last_slash + 1);
$file_name_with_ext = ($last_slash === FALSE)?$filepath:substr($filepath, $last_slash + 1);
$last_dot = strlen($file_name_with_ext) - strlen(strrchr($file_name_with_ext, "."));
$file_name = ($last_dot === FALSE)?"":substr($file_name_with_ext, 0, $last_dot);
$file_ext = ($last_dot === FALSE)?$file_name_with_ext:substr($file_name_with_ext, $last_dot + 1);
return array("FILEPATH" => $filepath,
"PATH" => $path_name,
"FILENAMEEXT" => $file_name_with_ext,
"FILENAME" => $file_name,
"FILEEXT" => $file_ext);
}
// testing
$filepath = "/usr/local/apache/htdocs/this.is.my.filename.php";
$filename_info = get_filename_info($filepath);
var_dump($filename_info);
// output
array(5) {
["FILEPATH"]=>
string(48) "/usr/local/apache/htdocs/this.is.my.filename.php"
["PATH"]=>
string(25) "/usr/local/apache/htdocs/"
["FILENAMEEXT"]=>
string(23) "this.is.my.filename.php"
["FILENAME"]=>
string(19) "this.is.my.filename"
["FILEEXT"]=>
string(3) "php"
}
Hope this may help you.
Chonla!!
----
Server IP: 203.121.145.116
Probable Submitter: 58.10.128.175
----
Manual Page -- http://www.php.net/manual/en/function.filetype.php
Edit -- https://master.php.net/note/edit/73323
Del: integrated -- https://master.php.net/note/delete/73323/integrated
Del: useless -- https://master.php.net/note/delete/73323/useless
Del: bad code -- https://master.php.net/note/delete/73323/bad+code
Del: spam -- https://master.php.net/note/delete/73323/spam
Del: non-english -- https://master.php.net/note/delete/73323/non-english
Del: in docs -- https://master.php.net/note/delete/73323/in+docs
Del: other reasons-- https://master.php.net/note/delete/73323
Reject -- https://master.php.net/note/reject/73323
Search -- https://master.php.net/manage/user-notes.php