PHP Programing language

chop() Functions in PHP
Previous Home Next
adplus-dvertising

chop()

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

Syntax:
chop(string,charlist)

In above syntax, "string" specifies the string to check and "charlist" specifies which characters to remove from the string is as follows:

  • "\0" - NULL
  • "\t" - tab
  • "\n" - new line
  • "\x0B" - vertical tab
  • "\r" - carriage return
  • " " - ordinary white space

Example:

chop(string,charlist)<?php
$str = "Gud Morning!\n\n";
echo $str;
echo chop($str);
?>

Output:

Gud Morning! Gud Morning!

Previous Home Next