note 37276 deleted from function.basename by cmb

From: Date: Fri, 14 Oct 2016 17:29:16 +0000
Subject: note 37276 deleted from function.basename by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206897@lists.php.net to get a copy of this message
Note Submitter: giovanni at giacobbi dot net ---- No comments here seems to take care about UNIX system files, which typically start with a dot, but they are not "extensions-only". The following function should work with every file path. If not, please let me know at my email address. <?php function remove_ext($str) { $noext = preg_replace('/(.+)\..*$/', '$1', $str); print "input: $str\n"; print "output: $noext\n\n"; } remove_ext("/home/joh.nny/test.php"); remove_ext("home/johnny/test.php"); remove_ext("weirdfile."); remove_ext(".hiddenfile"); remove_ext("../johnny.conf");

« previous php.notes (#206897) next »