php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9315 Weird array behavior
Submitted: 2001-02-17 07:21 UTC Modified: 2001-04-10 10:00 UTC
From: jeroen at vanoijen dot nl Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.0.4pl1 OS: Linux
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: jeroen at vanoijen dot nl
New email:
PHP Version: OS:

 

 [2001-02-17 07:21 UTC] jeroen at vanoijen dot nl
Php only finds the last row of the second file to be excisting in the array; even if all the rows are the same.

// Open file with 2 columns and parse into array
if ($fd = @fopen("int-osocat.txt", "r")) {
  while (!feof($fd)) {
     $line = fgets($fd, 4096);
     $intercat = strtok($line, "\t");
     $osocat =  strtok("\t");
     $key = $intercat;
     $catvars[$key]["active"] = 1;
     $catvars[$key]["osocat"] = $osocat;
  }
fclose ($fd);
}

// open second file, and check contents against array
if ($fd = @fopen("art-intcat.txt", "r")) {
  while (!feof($fd)) {
     $line = fgets($fd, 4096);
     $artikelnr = strtok($line, "\t");
     $intcat =  strtok("\t");
     $key2 = $intcat;
        if ($catvars[$key2]["active"]== 1) {
          echo $artikelnr . "\t" . $catvars[$key2]["osocat"] . "<br>";
        }
  }
fclose ($fd);
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-17 10:24 UTC] andre@php.net
Please provide a reduced code fragment (<15 lines) producing
this behaviour.
Put no database queries etc. in it and rely on no external
files to ensure that we can reproduce it easily unless the
problem is not directly related to some db (or similar)
function.
 [2001-04-10 10:00 UTC] sniper@php.net
No feedback. If this happens also with soon to be released 
PHP 4.0.5, reopen this bug report with a short example 
script that can be used to reproduce this.

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 05:01:31 2024 UTC