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
  • Convert binary data to hexadecimal representation bin2hex

    bin2hex

    Convertbinarydatatoh
  • One-way string hash crypt

    crypt

    One-waystringhash
  • Insert HTML newline tag before all new lines of a string nl2br

    nl2br

    InsertHTMLnewlinetag
  • Split the string into smaller chunks chunk_split

    chunk_split

    Splitthestringintosm
  • Convert the first byte of the string to a value between 0-255 ord

    ord

    Convertthefirstbyteo
  • Use uuencode to encode a string convert_uuencode

    convert_uuencode

    Useuuencodetoencodea
  • Remove spaces (or other characters) from the beginning of the string ltrim

    ltrim

    Removespaces(orother
  • Parses entered characters according to the specified format sscanf

    sscanf

    Parsesenteredcharact
Popular Articles