note 74585 added to function.trim
| From: | mark at crashandburn dot co dot uk | Date: | Wed, 18 Apr 2007 16:51:56 +0000 |
| Subject: | note 74585 added to function.trim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125554@lists.php.net to get a copy of this message | ||
I needed a simple function to do what trim does, but with the second parameter acting as ADDITIONAL
characters to trim, not the ONLY characters.
nice and simple:
<?php
function mytrim($string, $params = null)
{
if ($params)
{
// double trim - one for $params, and then a regular trim
$string = trim(trim($string, $params));
}
else
{
$string = trim($string);
}
return $string;
}
?>
which can be further simplified, but helped me when i needed to remove trailing slashes from a path
as well as other bits.
----
Server IP: 194.145.210.3
Probable Submitter: 86.154.64.0
----
Manual Page -- http://www.php.net/manual/en/function.trim.php
Edit -- https://master.php.net/note/edit/74585
Del: integrated -- https://master.php.net/note/delete/74585/integrated
Del: useless -- https://master.php.net/note/delete/74585/useless
Del: bad code -- https://master.php.net/note/delete/74585/bad+code
Del: spam -- https://master.php.net/note/delete/74585/spam
Del: non-english -- https://master.php.net/note/delete/74585/non-english
Del: in docs -- https://master.php.net/note/delete/74585/in+docs
Del: other reasons-- https://master.php.net/note/delete/74585
Reject -- https://master.php.net/note/reject/74585
Search -- https://master.php.net/manage/user-notes.php