Zend - The PHP Company




Text

Add Code


strip_extension  

Type: code fragment
Added by: deekayen2
Entered: 31/10/2001
Last modified: 01/11/2000
Rating: - (fewer than 3 votes)
Views: 4371
Strip the file extension from a filename.


<?php

/***************************************
** Title.........: Strip Extension
** Author........: David Norman <deekayen (at) deekayen [dot] net>
** Filename......: strip_extension.php
** Last changed..: 31 October 2001
** License.......: Free to use. If you find it useful
**                 though, feel free to buy me something
**                 from my wishlist :)
**                 http://www.amazon.com/exec/obidos/wishlist/002-4690657-2090415
***************************************/

/***************************************
** Set the filename to a variable.
** This can be derived from a fully qualified
** URL by using the basename() function
***************************************/

$text "index.php";

/***************************************
** Assign the name of the file to a varable
** and print it.
***************************************/

$first substr($text0strrpos($text'.'));
echo 
$first;

echo 
"<br/><br/>";

/***************************************
** Assign the file extension to a variable
** and print it.
***************************************/

$extension substr($textstrrpos($text'.'), strlen($text));
echo 
$extension;

?>


Usage Example




Rate This Script





Search



This Category All Categories