php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20005 trim does not trim a string in array
Submitted: 2002-10-21 04:04 UTC Modified: 2002-10-21 04:12 UTC
From: chris at xwave dot ch Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.2.3 OS: Linux suse 2.4.16-4GB
Private report: No CVE-ID: None
 [2002-10-21 04:04 UTC] chris at xwave dot ch
I've got this code segement:
--- snip ---
$buffer = fgets($if);
$e = split("\t", trim($buffer));
for ($ic = 0 ; $ic > count($e); $ic++) {
   $e[$ic] = trim($e[$ic]);
}
--- snap ---

The string in the array $e[] is never trimmed. In it does just the same as $e[$ic] = $e[$ic];
Same behaviour in chop!

When I changed the code to this:
--- snip ---
$buffer = fgets($if);
$b = trim($buffer);
$e = split("\t", $b);
for ($ic = 0 ; $ic < count($e); $ic++) {
   $t[$ic] = trim($e[$ic]);
}
--- snap ---

it works as expected.

Chris

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-21 04:09 UTC] sander@php.net
for ($ic = 0 ; $ic > count($e); $ic++) {
                  ^^^
That should be < of course.
 [2002-10-21 04:12 UTC] chris at xwave dot ch
Stupid myself. thx...

Chris
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Oct 22 14:01:27 2019 UTC