note 71797 added to function.basename

From: Date: Sat, 16 Dec 2006 16:25:46 +0000
Subject: note 71797 added to function.basename
Groups: php.notes 
Request: Send a blank email to php-notes+get-120652@lists.php.net to get a copy of this message
Here's my function which parses out the parts of a path. It will parse out multiple extensions for files like "archive.tar.gz", returning "archive" as the basename. // EXAMPLE print_r(filename_parts("./path/filename.tar.gz")); // YIELDS Array ( [full] => ./path/filename.tar.gz [folder] => ./path/ [filename] => filename.tar.gz [basename] => filename [full_extension] => .tar.gz [extension] => gz ) // DEFINITION function filename_parts($file) { preg_match('/(.*?)(([^\\/\\\\]+?)((?:[.](\w*))*)?)$/', $file, $match); debug($match); list($full, $folder, $filename, $basename, $full_extension, $extension) = $match; return array( "full" => $full, "folder" => $folder, "filename" => $filename, "basename" => $basename, "full_extension" => $full_extension, "extension" => $extension ); } ---- Server IP: 66.163.161.117 Probable Submitter: 69.115.97.79 ---- Manual Page -- http://www.php.net/manual/en/function.basename.php Edit -- https://master.php.net/note/edit/71797 Del: integrated -- https://master.php.net/note/delete/71797/integrated Del: useless -- https://master.php.net/note/delete/71797/useless Del: bad code -- https://master.php.net/note/delete/71797/bad+code Del: spam -- https://master.php.net/note/delete/71797/spam Del: non-english -- https://master.php.net/note/delete/71797/non-english Del: in docs -- https://master.php.net/note/delete/71797/in+docs Del: other reasons-- https://master.php.net/note/delete/71797 Reject -- https://master.php.net/note/reject/71797 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120652) next »