Easy Tutorial
❮ Func Mysqli Change User Func String Md5 ❯

PHP chop() Function

PHP String Reference Manual

Example

Remove characters from the right side of a string:


Definition and Usage

The chop() function removes whitespace or other predefined characters from the right side of a string.


Syntax

Parameter Description
string Required. Specifies the string to check.
charlist Optional. Specifies which characters to remove from the string. <br>If the charlist parameter is empty, the following characters are removed: "\0" - NULL<br> "\t" - Tab<br> "\n" - Newline<br> "\x0B" - Vertical tab<br> "\r" - Carriage return<br> " " - Space

Technical Details

Return Value: Returns the modified string.
PHP Version: 4+
--- ---
Changelog: The charlist parameter was added in PHP 4.1.0.
--- ---

More Examples

Example 1

Remove newline characters (\n) from the right side of a string:

HTML output of the above code (view source):

Browser output of the above code:


❮ Func Mysqli Change User Func String Md5 ❯