YouTip LogoYouTip

Func String Chop

# PHP chop() Function [![Image 3: PHP String Reference](#) PHP String Reference](#) ## Example Remove characters from the right side of a string: <?php $str = "Hello World!"; echo $str . "
"; echo chop($str,"World!"); ?> [Run Example Β»](#) * * * ## Definition and Usage The chop() function removes whitespace or other predefined characters from the right side of a string. * * * ## Syntax chop(_string,charlist_) | Parameter | Description | | --- | --- | | _string_ | Required. The string to be checked. | | _charlist_ | Optional. Specifies which characters to remove from the string. If the charlist parameter is empty, the following characters are removed: * "" - NULL * "t" - tab * "n" - newline * "x0B" - vertical tab * "r" - carriage return * " " - 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: The HTML output of the above code is as follows (view source): Hello World! Hello World! The browser output of the above code is as follows: Hello World! Hello World! [Run Example Β»](#) * * PHP String Reference](#)
← Func String ChrFunc String Bin2Hex β†’