Current Location: Home> Function Categories> chop

chop

Alias ​​of rtrim
Name:chop
Category:String
Programming Language:php
One-line Description:Delete whitespace characters or other characters to the right of the string.

Definition and usage

The chop() function removes whitespace characters or other predefined characters at the right end of the string.

Example

Example 1

Remove characters from the right end of the string:

 <?php
$str = "Hello World!" ;
echo $str . "<br>" ;
echo chop ( $str , "World!" ) ;
?>

Try it yourself

Example 2

Remove the newline character (\n) to the right of the string:

 <?php
$str = "Hello World!\n\n" ;
echo $str ;
echo chop ( $str ) ;
?>

The HTML output of the above code is as follows (see the source code):

 < ! DOCTYPE html >
< html >

< body >

Hello World !

Hello World !

< / body >
< / html >

The browser output of the above code is as follows:

 Hello World! Hello World! Hello World!

Try it yourself

Similar Functions
Popular Articles