note 93829 deleted from function.strrpos by mazzanet
| From: | mazzanet@php.net | Date: | Sun, 25 Dec 2011 00:46:03 +0000 |
| Subject: | note 93829 deleted from function.strrpos by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185234@lists.php.net to get a copy of this message | ||
Note Submitter: jriddy at obfuscation dot isnt dot spam-safe dot com
----
If you're trying to do what "Alexandre" did a few posts below this one, that is,
removing trailing slashes, just use rtrim() for simple stuff, and a preg function for more
complicated removals.
Either one of the following functions will remove a trailing slash unless it's a root folder.
<?php
function trimTrailingSlashes1( $str ) {
// It's always a good idea to do this just to make sure.
$str = trim($str);
// If it's root, don't rtrim() the only slash away.
// Passing a character mask to rtrim makes it look for the
// characters you specify.
return $str == '/' ? $str : rtrim($str, '/');
}
?>