Table of Contents

Syntax

string chop(string $str [, string $charlist])

(PHP 4, PHP 5)

$str The string to manipulate (trim whitespace)
$charlist Optional string of characters to strip from the right side of $str
RETURNS Returns the modified string with the specified characters removed

What it Does

This function is an alias for the rtrim function. It trims specific characters (specified by $charlist) from the end of the string argument. If the optional $charlist argument is not specified, all whitespace characters will be removed.

Example

$test = chop("Something \t \n ");
echo '*' . $test . '*';

Outputs:

*Something*