The chop() function in PHP is used to remove whitespace.
Syntax
chop(str, charlist)
Parameters
str − String to be escaped.
charlist − Specify the characters that should be removed.
Return
The chop() function
Example
The following is an example −
<?php $str = "Demo Text!"; echo $str . " "; echo chop($str,"Text!"); ?>
Output
Demo Text! Demo
Example
Let us see another example −
<?php $str = "Welcome \nto the \nwebsite \n"; echo $str; echo chop($str); ?>
Output
Welcome to the website Welcome to the website