note 96598 added to book.array

From: Date: Sun, 07 Mar 2010 14:15:34 +0000
Subject: note 96598 added to book.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-166751@lists.php.net to get a copy of this message
If an array item is declared with key as NULL, array key will automatically be converted to empty string '', as follows: <?php $a = array( NULL => 'zero', 1 => 'one', 2 => 'two'); // This will show empty string for key associated with "zero" value var_dump(array_keys($a)); // Array elements are shown reset($a); while( key($a) !== NULL ) { echo key($a) . ": ".current($a) . "<br>";// PHP_EOL next($a); } // Array elements are not shown reset($a); while( key($a) != NULL ) // '' == null => no iteration will be executed { echo key($a) . ": ".current($a) . "<br>";// PHP_EOL next($a); } ---- Server IP: 69.147.83.197 Probable Submitter: 89.41.229.5 ---- Manual Page -- http://www.php.net/manual/en/book.array.php Edit -- https://master.php.net/note/edit/96598 Del: integrated -- https://master.php.net/note/delete/96598/integrated Del: useless -- https://master.php.net/note/delete/96598/useless Del: bad code -- https://master.php.net/note/delete/96598/bad+code Del: spam -- https://master.php.net/note/delete/96598/spam Del: non-english -- https://master.php.net/note/delete/96598/non-english Del: in docs -- https://master.php.net/note/delete/96598/in+docs Del: other reasons-- https://master.php.net/note/delete/96598 Reject -- https://master.php.net/note/reject/96598 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#166751) next »