note 96421 modified in function.basename by danbrown
| From: | danbrown@php.net | Date: | Fri, 26 Feb 2010 19:27:43 +0000 |
| Subject: | note 96421 modified in function.basename by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166413@lists.php.net to get a copy of this message | ||
you could use this function when you need basename to work with cyrillic filenames
<?php
function pcgbasename($param, $suffix=null) {
if ( $suffix ) {
$tmpstr = ltrim(substr($param, strrpos($param, DIRECTORY_SEPARATOR) ), DIRECTORY_SEPARATOR);
if ( (strpos($param, $suffix)+strlen($suffix) ) == strlen($param) ) {
return str_ireplace( $suffix, '', $tmpstr);
} else {
return ltrim(substr($param, strrpos($param, DIRECTORY_SEPARATOR) ), DIRECTORY_SEPARATOR);
}
} else {
return ltrim(substr($param, strrpos($param, DIRECTORY_SEPARATOR) ), DIRECTORY_SEPARATOR);
}
}
?>
--was--
you could use this function when you need basename to work with cyrillic filenames
function pcgbasename($param, $suffix=null) {
if ( $suffix ) {
$tmpstr = ltrim(substr($param, strrpos($param, DIRECTORY_SEPARATOR) ), DIRECTORY_SEPARATOR);
if ( (strpos($param, $suffix)+strlen($suffix) ) == strlen($param) ) {
return str_ireplace( $suffix, '', $tmpstr);
} else {
return ltrim(substr($param, strrpos($param, DIRECTORY_SEPARATOR) ), DIRECTORY_SEPARATOR);
}
} else {
return ltrim(substr($param, strrpos($param, DIRECTORY_SEPARATOR) ), DIRECTORY_SEPARATOR);
}
}
http://php.net/manual/en/function.basename.php