CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Post a PHP snippet (http://www.codingforums.com/forumdisplay.php?f=41)
-   -   Add ending slash (http://www.codingforums.com/showthread.php?t=197691)

itxen 06-08-2010 11:14 AM

Add ending slash
 
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

PHP Code:

$path rtrim$pathDIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR


saviola 06-10-2010 05:51 PM

Quote:

Originally Posted by kbluhm (Post 962504)
PHP Code:

$path rtrim$pathDIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR


simple and useful :thumbsup:


All times are GMT +1. The time now is 10:51 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.