note 37057 added to function.chop
| From: | php at newmediaone dot com | Date: | Sat, 01 Nov 2003 03:54:03 +0000 |
| Subject: | note 37057 added to function.chop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59611@lists.php.net to get a copy of this message | ||
The above notes are confusing 2 different Perl fuctions, chop and chomp.
In Perl, chop removes and returns the last charecter of a string. This function was often used in
Perl <= version 4 to remove newlines, and in some cases, you'd think you were choping a new
line, but if the last charecter wan't a newline, chop would still remove it.
As of Perl 5, chomp (note the "m") was introducted. Chomp removes the last character(s)
of a string only if those chatecters are new lines, and it returns the number of characters deleted.
(If the string ends in multiple newlines, they will all be choped off, and if the last charecter is
not a new line, nothing will be choped off.)
So, I don't think either of the above examples quite duplicate Perl's chomp, but they are
both very helpful.
----
Manual Page -- http://www.php.net/manual/en/function.chop.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37057
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37057&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37057&report=yes
Search -- http://master.php.net/manage/user-notes.php