note 39269 deleted from function.strrchr by nlopess

From: Date: Thu, 22 Jan 2004 16:51:01 +0000
Subject: note 39269 deleted from function.strrchr by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-64025@lists.php.net to get a copy of this message
Note Submitter: eshenk@comcast.net ---- I use a showimage script to place an image into my website framework, and wanted a way to clean up the file extension so it could be used in a header tag for a caption of sorts. I expanded the code and heavily commented it for this note. <?php // Underscore and file extension murderizer // By Enos Shenk $text = "here_is_my_image.jpeg"; // Starting filename $extension = strrchr($text, "."); // Get the file extension $extlen = strlen($extension); // Length of extension $len = strlen($text) - $extlen; // Get the length of the filename minus extension $trimmed = substr($text,0,$len); // Only take the set length, no extension $out = str_replace("_", " ", $trimmed); // Finally, replace _ with space echo $out; // All done ?>

« previous php.notes (#64025) next »