Hallo,
I am adding a value to a session variable (an array). Then I want to place 
the key of the array in another session variable to keep it for later use 
(so I can return to the array to write data to it). The key function should 
work there, but it seems to be a bit strange.

Imagine:

$array = array();
$array[] = "Yellow";
$array[] = "Geen";
$array[] = "Red";

foreach ($array as $key=>$value)
{
    print ("Key: " . $key . " has color " . $value . " | ");
    print ("current key = " . key($array) . "<br/>");
}

If you run the loop the key value returned from key is one higher than the 
key in $key, and the last key is null?

How do I get the present key without a problem??

Thanks!! 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to