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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: chris at xwave dot ch
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 22:01:27 2024 UTC