...

View Full Version : Add ending slash



itxen
06-08-2010, 11:14 AM
function add_ending_slash($path){

$slash_type = (strpos($path, '\\')===0) ? 'win' : 'unix';

$last_char = substr($path, strlen($path)-1, 1);

if ($last_char != '/' and $last_char != '\\') {
// no slash:
$path .= ($slash_type == 'win') ? '\\' : '/';
}

return $path;
}

kbluhm
06-08-2010, 01:47 PM
$path = rtrim( $path, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR;

saviola
06-10-2010, 05:51 PM
$path = rtrim( $path, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR;

simple and useful :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum