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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 04:01:27 2024 UTC