PHP chop() Function


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

Syntax
chop(string,character)
Parameters
  • string - (Required) Specifies the string to check.
  • character - (Optional) Characters to remove from the string.
    	If the parameter is empty, the following characters are removed. 
    	“\0” – NULL 
    	“\t” – tab 
    	“\n” – line break 
    	“\x0B” – vertical tab 
    	“\r” – carriage return 
    	" " - normal whitespace
    
Example
<?php
echo "Hello World\t\t";
echo "Hello World";
?>

Output

Hello World Hello World

Prev Next