Voting

: seven minus four?
(Example: nine)

The Note You're Voting On

pLIMP
11 years ago
Function similar to rtrim only this will truncate the string at the 1st occurence of any character from $charlist

<?php

function rstrip($string, $charlist = "\t ") {
// removes everything from first occurence of char in charlist to end of string

$charlist = str_split($charlist);
$pos = strlen($string);

foreach (
$charlist as $char) {
$pos = min(strpos($string, $char), $pos);
}

$string_stripped = substr($string, 0, $pos);

return
$string_stripped;
}

?>

<< Back to user notes page

To Top