weird foreach problem when calling date or getdate function, variable does not change
| From: | Zachary Buckholz | Date: | Sun, 05 May 2002 05:05:39 +0000 |
| Subject: | weird foreach problem when calling date or getdate function, variable does not change | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-96111@lists.php.net to get a copy of this message | ||
The following block of code loops over an array but when I call the PHP
function date or getdate the variable used in this function is always the
first one used in the array. What am I doing wrong? The sample output is
below.
foreach ($results_array as $array) {
//$time = date("H:i:s", $array[0]);
$time = getdate($array[0]);
$chk_status = $array[1];
$resp_sec = $array[2];
print "$array[0] <br>";
print "$time[hours]:$time[minutes]:$time[seconds] = $chk_status = $resp_sec
<br>";
array_push ($array_time, $time);
//array_push ($array_status, $chk_status);
array_push ($array_resp, $resp_sec);
}
20020504160503 <-- Notice how this date/time value is updated
properly each loop
20:14:7 = 200 = 2 <-- Notice how this value always remains the same?
20020504160702
20:14:7 = 200 = 1
20020504160903
20:14:7 = 200 = 1
20020504161101
20:14:7 = 200 = 1
20020504161302
20:14:7 = 200 = 1
20020504161502
20:14:7 = 200 = 1
20020504161702
20:14:7 = 200 = 2
20020504161901
20:14:7 = 200 = 1
20020504162101
20:14:7 = 200 = 1
20020504162301
20:14:7 = 200 = 1
20020504162701
20:14:7 = 200 = 1
20020504162901
20:14:7 = 200 = 1
20020504163102
20:14:7 = 200 = 1
20020504163302
20:14:7 = 200 = 1
20020504163509
20:14:7 = 200 = 6
20020504163702
20:14:7 = 200 = 1
20020504163901
20:14:7 = 200 = 1
20020504164101
20:14:7 = 200 = 1
20020504164301
20:14:7 = 200 = 1
20020504164502
20:14:7 = 200 = 1
20020504164702
20:14:7 = 200 = 1
20020504164905
20:14:7 = 200 = 1
20020504165103
20:14:7 = 200 = 1
20020504165301
20:14:7 = 200 = 1
20020504165502
20:14:7 = 200 = 1
20020504165701
20:14:7 = 200 = 1
20020504165902
20:14:7 = 200 = 1
20020504170101
20:14:7 = 200 = 1