PHP chop() Function

PHP chop() function is used to remove whitespace from the end of a string.

Syntax

string chop(str,charlist);

chop() Function Parameter

ParameterDescription
str :Required parameter. A string or text.
charlist :Optional parameter. Characters to be remove from the string.

chop() Function Return Value

Return Value :Returns the modified string.

chop() Function Example

<?php
echo chop("Hello world!   ");
?>