note 113083 added to function.ltrim
| From: | Anonymous | Date: | Tue, 27 Aug 2013 20:26:09 +0000 |
| Subject: | note 113083 added to function.ltrim | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196098@lists.php.net to get a copy of this message | ||
pLIMP's function for removing everything from the start of the string to the last occurence of
anything in the $charlist yielded an undefined variable notice for the variable $pos. Define the
variable as NULL before entering the foreach statement, as follows:
<?php
function lstrip($string, $charlist) {
// removes everything from start of string to last occurence of char in charlist
$pos=NULL;
$charlist = str_split($charlist);
foreach ($charlist as $char) {
$pos = max(strrpos($string, $char), $pos);
}
$string_stripped = substr($string, $pos + 1);
return $string_stripped;
}
?>
Not a knock. Just a note to help someone.
Thank you pLIMP!
----
Server IP: 69.147.83.199
Probable Submitter: 199.48.203.2
----
Manual Page -- http://php.net/manual/en/function.ltrim.php
Edit -- https://master.php.net/note/edit/113083
Del: integrated -- https://master.php.net/note/delete/113083/integrated
Del: useless -- https://master.php.net/note/delete/113083/useless
Del: bad code -- https://master.php.net/note/delete/113083/bad+code
Del: spam -- https://master.php.net/note/delete/113083/spam
Del: non-english -- https://master.php.net/note/delete/113083/non-english
Del: in docs -- https://master.php.net/note/delete/113083/in+docs
Del: other reasons-- https://master.php.net/note/delete/113083
Reject -- https://master.php.net/note/reject/113083
Search -- https://master.php.net/manage/user-notes.php