php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9120 unexpected behavior of chop(), ltrim(), rtrim(), and trim()
Submitted: 2001-02-05 16:51 UTC Modified: 2001-03-20 05:54 UTC
From: artymiak at safenet dot pl Assigned:
Status: Closed Package: Strings related
PHP Version: 4.0.3pl1 OS: OpenBSD 2.7
Private report: No CVE-ID: None
 [2001-02-05 16:51 UTC] artymiak at safenet dot pl
chop(), trim(), ltrim(), and rtrim() do not remove \v, \r, or \n.

# chop();

echo "<p><pre>                chop()";
echo "<br>                ------------------<br>";
$x = "     ab cd ef     \v\r\n" ;
echo strlen($x) . " characters: |" . $x . "|<br>";
$y = chop($x);
echo strlen($y) . " characters: |" . $y . "|</pre></p>";

# ltrim();

echo "<p><pre>                ltrim()";
echo "<br>                ------------------<br>";
$x = "\v\r\n     ab cd ef     " ;
echo strlen($x) . " characters: |" . $x . "|<br>";
$y = ltrim($x);
echo strlen($y) . " characters: |" . $y . "|</pre></p>";

# rtrim();

echo "<p><pre>                rtrim()";
echo "<br>                ------------------<br>";
$x = "     ab cd ef     \v\r\n" ;
echo strlen($x) . " characters: |" . $x . "|<br>";
$y = rtrim($x);
echo strlen($y) . " characters: |" . $y . "|</pre></p>";

#
# trim();

echo "<p><pre>                trim()";
echo "<br>                ------------------<br>";
$x = "  \v\r\n   ab cd ef  \v\r\n   " ;
echo strlen($x) . " characters: |" . $x . "|<br>";
$y = trim($x);
echo " " . strlen($y) . " characters: |" . $y . "|</pre></p>";

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-20 05:54 UTC] stas@php.net
Works for me perfectly - except that \v is not recognized by
PHP. Who needs it anyway?.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC