note 74947 deleted from function.basename by tularis

From: Date: Sat, 05 May 2007 18:21:03 +0000
Subject: note 74947 deleted from function.basename by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126223@lists.php.net to get a copy of this message
Note Submitter: egil at wp dot pl Reason: useless ---- Using functions like explode if you don't have too, is not a very wise thing to do... A simple function like the one below should work with any standard query strings. <?php function basename_q ($qstring) { $q_pos = strpos($qstring,'?'); if ($q_pos===false) return basename($qstring); else return basename(substr($qstring, 0, $q_pos)); } echo basename_q ('somethin/stuff.php?some=query&other=stuff')."<br/>\n"; echo basename_q ('somethin/stuff.php')."<br/>\n"; ?> The above will output: stuff.php stuff.php

« previous php.notes (#126223) next »