note 32655 added to function.chop
| From: | zebadger at excite dot php dot net | Date: | Tue, 03 Jun 2003 22:27:28 +0000 |
| Subject: | note 32655 added to function.chop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-49668@lists.php.net to get a copy of this message | ||
The perl version of chomp only removes newlines. I modified the previous code to do that.
function chomp(&$string)
{
if (is_array($string))
{
foreach($string as $i => $val)
{
$endchar = chomp($string[$i]);
}
} else {
$endchar = substr("$string", strlen("$string") - 1, 1);
if ($endchar == "\n")
{
$string = substr("$string", 0, -1);
}
}
return $endchar;
}
----
Manual Page -- http://www.php.net/manual/en/function.chop.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32655
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32655&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32655&report=yes