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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
23 - 3 = ?
Subscribe to this entry?

 
 [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: Fri Mar 29 13:01:29 2024 UTC