The following code:
<?php
$str='Who are you?';
echo chop($str,'you?').'<br>';
echo chop($str,'are you?').'<br>';
?>
gives me the output:
Who are
Wh
Why the second output is
Wh
and not
who
because:
(PHP 4, PHP 5, PHP 7)
chop— Alias ofrtrim()
and
(PHP 4, PHP 5, PHP 7)
rtrim— Strip whitespace (or other characters) from the end of a string
string rtrim ( string $str [, string $character_mask ] )
So... you're feeding a character mask.
Given that, "o" is in that mask, so it gets trimmed out
In your string you have specified a character_mask, this is what reference says:
character_mask: You can also specify the characters you want to strip, by means of the character_mask parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters.
In your case, there's an 'o' in the mask, for this reason all 'o' in $str have been deleted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With