note 35108 added to function.rtrim

From: Date: Tue, 19 Aug 2003 23:19:12 +0000
Subject: note 35108 added to function.rtrim
Groups: php.notes 
Request: Send a blank email to php-notes+get-54722@lists.php.net to get a copy of this message
This shows how rtrim works when using the optional charlist parameter: rtrim reads a character, one at a time, from the optional charlist parameter and compares it to the end of the str string. If the characters match, it trims it off and starts over again, looking at the "new" last character in the str string and compares it to the first character in the charlist again. If the characters do not match, it moves to the next character in the charlist parameter comparing once again. It continues until the charlist parameter has been completely processed, one at a time, and the str string no longer contains any matches. The newly "rtrimmed" string is returned. <?php // Example 1: rtrim('This is a short short sentence', 'short sentence'); // returns 'This is a' // If you were expecting the result to be 'This is a short ', // then you're wrong; the exact string, 'short sentence', // isn't matched. Remember, character-by-character comparison! // Example 2: rtrim('This is a short short sentence', 'cents'); // returns 'This is a short short ' ?> ---- Manual Page -- http://www.php.net/manual/en/function.rtrim.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35108 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35108&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35108&report=yes

« previous php.notes (#54722) next »