note 103311 deleted from function.list by googleguy

From: Date: Thu, 13 Sep 2012 10:00:48 +0000
Subject: note 103311 deleted from function.list by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190693@lists.php.net to get a copy of this message
Note Submitter: boukeversteegh at gmail dot com ---- If your array is shorter than the number of arguments in list(), you will get an "undefined index" notice. You can solve it by making sure the array is long enough: <?php $array = Array( "one", "two" ); # This will give a Notice: undefined index [2]: list( $one, $two, $three ) = $array; # This won't: list( $one, $two, $three ) = $array + Array( null, null, null ); # If you know count($array) will be at least 1, you could skip the first index: list( $one, $two, $three ) = $array + Array( 1 => null, null ); # You could of course also use other default values: list( $one, $two, $three ) = $array + Array( "one", "two", "three" ); ?>

« previous php.notes (#190693) next »