Adding in PHP

From: Date: Fri, 03 Nov 2000 21:49:48 +0000
Subject: Adding in PHP
Groups: php.general 
Request: Send a blank email to php-general+get-23644@lists.php.net to get a copy of this message
A little Background: Environment : PHP 4 used as an Apache module on a Sparc/Solaris 6 machine. Concerning : Array of Array(s) and/or numeric limits. Variables set outside of function: $date_count is an array with keys and values such as below (except mine are generated dynamically from a database call): $date_count array('22-OCT-2000' => '2664' '21-OCT-2000' => '2488' '20-OCT-2000' => '5377' '19-OCT-2000' => '5377' '18-OCT-2000' => '4625' '17-OCT-2000' => '4782' '16-OCT-2000' => '4904' '15-OCT-2000' => '2076' '14-OCT-2000' => '2306' '13-OCT-2000' => '4337' '12-OCT-2000' => '3992' '11-OCT-2000' => '4245' '10-OCT-2000' => '4260' '09-OCT-2000' => '4051'); Problem part of the Class function: <?php //the problem snippet $oldcount = 0; while(list($date,$count) = each ($date_count)) { if(substr($date,3,3) == $month_arr2[$s]) { $newcount = ($oldcount + $count); print("$date is $oldcount + $count = $newcount <br />"); $oldcount = $count; } else { $s++; } } ?> This is the output: 22-OCT-2000 is 0 + 2664 = 2664 21-OCT-2000 is 2664 + 2488 = 5152 20-OCT-2000 is 2488 + 5139 = 7627 19-OCT-2000 is 5139 + 5377 = 10516 18-OCT-2000 is 5377 + 4625 = 10002 17-OCT-2000 is 4625 + 4782 = 9407 <!-- *Take Note --> 16-OCT-2000 is 4782 + 4904 = 9686 15-OCT-2000 is 4904 + 2076 = 6980 14-OCT-2000 is 2076 + 2306 = 4382 13-OCT-2000 is 2306 + 4337 = 6643 12-OCT-2000 is 4337 + 3992 = 8329 11-OCT-2000 is 3992 + 4245 = 8237 10-OCT-2000 is 4245 + 4260 = 8505 09-OCT-2000 is 4260 + 4051 = 8311 * Why does it stop adding after the 5th loop?

« previous php.general (#23644) next »