note 56084 added to function.basename

From: Date: Tue, 23 Aug 2005 00:47:55 +0000
Subject: note 56084 added to function.basename
Groups: php.notes 
Request: Send a blank email to php-notes+get-94058@lists.php.net to get a copy of this message
I was looking for a way to get only the filename whether or not I had received the full path to it from the user. I came up with a much simpler (and probably more robust) method by using the power of basename in reverse: $infile = "/usr/bin/php"; $filename = stristr ($infile,basename ($infile)); This even works on those _wacky_ filenames like "/usr/lib/libnetsnmp.so.5.0.9" which are not factored when exploding the full path and taking out only the last segment after "." ---- Manual Page -- http://www.php.net/manual/en/function.basename.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56084 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56084&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56084&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56084&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56084&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56084&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56084&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56084&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94058) next »