PHP 4.0 Bug #9315: Weird array behavior
| From: | jeroen at vanoijen dot nl | Date: | Sat, 17 Feb 2001 12:21:14 +0000 |
| Subject: | PHP 4.0 Bug #9315: Weird array behavior | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-46778@lists.php.net to get a copy of this message | ||
From: jeroen@vanoijen.nl
Operating system: Linux
PHP version: 4.0.4pl1
PHP Bug Type: Arrays related
Bug description: Weird array behavior
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);
}
--
Edit Bug report at: http://bugs.php.net/?id=9315&edit=1