Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-08-2010, 11:14 AM   PM User | #1
itxen
New to the CF scene

 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
itxen is an unknown quantity at this point
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;
}

Last edited by vinyl-junkie; 06-08-2010 at 12:51 PM.. Reason: signatures only allowed through the control panel
itxen is offline   Reply With Quote
Old 06-08-2010, 01:47 PM   PM User | #2
kbluhm
Senior Coder

 
kbluhm's Avatar
 
Join Date: Apr 2007
Location: Philadelphia, PA, USA
Posts: 1,502
Thanks: 2
Thanked 258 Times in 254 Posts
kbluhm will become famous soon enough
PHP Code:
$path rtrim$pathDIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR
__________________
ZCE
kbluhm is offline   Reply With Quote
Old 06-10-2010, 05:51 PM   PM User | #3
saviola
New Coder

 
Join Date: Jun 2010
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
saviola is an unknown quantity at this point
Quote:
Originally Posted by kbluhm View Post
PHP Code:
$path rtrim$pathDIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR
simple and useful
saviola is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:29 PM.


Advertisement
Log in to turn off these ads.