note 117636 added to function.rtrim
| From: | andreipop2005 at gmail dot com | Date: | Mon, 13 Jul 2015 09:24:24 +0000 |
| Subject: | note 117636 added to function.rtrim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203090@lists.php.net to get a copy of this message | ||
Trim limit would be really helpfull. I made a little helper function to do a rtrim with a limited
number of replaces:
<?php
function rtrim_limit($str, $delim, $count = 0)
{
if ($count == 0) return rtrim($str, $delim);
$l = strlen($delim);
$k = 0;
while (substr($str, -$l) == $delim && ($count == 0 || ($count > 0 && $k++
< $count))) {
$str = substr($str, 0, strlen($str) - $l);
}
return $str;
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 86.120.224.216
----
Manual Page -- http://php.net/manual/en/function.rtrim.php
Edit -- https://master.php.net/note/edit/117636
Del: integrated -- https://master.php.net/note/delete/117636/integrated
Del: useless -- https://master.php.net/note/delete/117636/useless
Del: bad code -- https://master.php.net/note/delete/117636/bad+code
Del: spam -- https://master.php.net/note/delete/117636/spam
Del: non-english -- https://master.php.net/note/delete/117636/non-english
Del: in docs -- https://master.php.net/note/delete/117636/in+docs
Del: other reasons-- https://master.php.net/note/delete/117636
Reject -- https://master.php.net/note/reject/117636
Search -- https://master.php.net/manage/user-notes.php