note 31851 added to function.key
| From: | happy dot machine at skynet dot be | Date: | Tue, 06 May 2003 16:20:04 +0000 |
| Subject: | note 31851 added to function.key | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47587@lists.php.net to get a copy of this message | ||
$tab = array();
$tab[0] = 'php';
$tab[1] = '.';
$tab[2] = 'net';
// you will not enter the while
// $key = 0, while will consider $key as false
reset($tab);
while ($key = key($tab) ) {
echo $tab[$key];
next($tab);
}
// this will
reset($tab);
while (!is_null($key = key($tab) ) ) {
echo $tab[$key];
next($tab);
}
// when key() can't return a 'key', it return NULL
echo var_dump($key);
--
http://www.php.net/manual/en/function.key.php
http://master.php.net/manage/user-notes.php?action=edit+31851
http://master.php.net/manage/user-notes.php?action=delete+31851
http://master.php.net/manage/user-notes.php?action=reject+31851