Definition and usage
The chop () function removes white space characters or other predefined characters to the right of the string.
Grammar
Chop (string,charlist)
Chop performs the removal of whitespace processing, get_html_translation_table returns the conversion list to the variable, and defines the string that includes the HTML encoding Htmlentities,htmlspecialchars_decode Defines a string that contains HTML special characters, NL2BR Quotemeta RTrim, and so on.
Definition and Usage: the chop () function removes whitespace characters or other predefined characters from the end of the string, and aliases the function's RTrim () function.
Syntax: Chop (string,charlist), the code is as follows:
Copy the code code as follows:
$str = "I ' m a teacher "; Defines the string $result =chop ($STR); Perform the removal of whitespace to handle echo $result; Output results
Parameter description
string is required. Specifies the string to check.
Charlist is optional. Specifies which characters are removed from the string.
If the charlist parameter is empty, the following characters are removed:
"\"-NULL "\ T"-tab "\ n"-newline "\x0b"-vertical tab "\ r"-Carriage return ""-space
Technical details return value:
Returns the modified string.
Example 1
Remove the line break (\ 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 source code):
<! DOCTYPE Html>
The browser output of the above code is as follows:
Hello world! Hello world!