Php chop
From w3cyberlearnings
Contents |
PHP function chop
This function removes white space on the right end of a string.
Syntax chop
- string: string to use.
- charlist (Optional): \0 (NULL), \t (tab), \n (new line), \x0B (vertical tab), \r (a carriage return), "" (white space)
chop(string,charlist)
Example 1
<?php $mylist = "Hello world \n\n"; $mynew_list = chop($mylist); echo $mynew_list; ?>
Output
Remove \n\n
Hello world
Example 2
<?php $mylist = "Hello world "; $mynew_list = chop($mylist); echo $mylist .'good<br/>'; echo $mynew_list.'good'; ?>
Output
- Two different result: one with white space, and the second one without white space.
Hello world good Hello worldgood