Tutorialsplane

PHP chop Function


PHP chop Function : The Chop() function is used to remove the whitespaces or predefined character from right end of the string.

How to use PHP chop Function?

chop(string,charlist)

String: String to check.
charlist: Character List to be removed.
charlist : Following characters are removed if charlist is empty :

“\0” – NULL
“\t” – tab
“\n” – new line
“\x0B” – vertical tab
“\r” – carriage return
” ” – ordinary white space

function Example 2

$string = "Hey Buddy it's John";
$result = chop($string,"John");
echo $result;

Try it »

PHP chop Function Example

String With White Space At the End

PHP chop() function Example 2

$string = "Hey Buddy it's John ";
$result = chop($string);
echo $result;

Try it »

PHP String Functions