note 96279 deleted from function.array-pop by googleguy

From: Date: Mon, 17 Dec 2012 12:25:33 +0000
Subject: note 96279 deleted from function.array-pop by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192563@lists.php.net to get a copy of this message
Note Submitter: me at fxless dot org ---- I have used array_pop() in a function that returns the name of the current file. This can be used, for example, in conjunction with filemtime() to get the modification time of the current file. The function I coded is a one-liner: <?php function whoAmI(){ return array_pop(explode("/", $_SERVER['PHP_SELF'])); } ?> If your file URI is www.example.com/bar/foobar.php, whoAmI() will return foobar.php. To use it with e.g. filemtime() you would simply write: <?php $modtime = filemtime(whoAmI()); ?> Greetings, Jochen

« previous php.notes (#192563) next »