note 52802 added to function.list
| From: | php at keithtyler dot com | Date: | Thu, 12 May 2005 21:27:30 +0000 |
| Subject: | note 52802 added to function.list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89355@lists.php.net to get a copy of this message | ||
Note to perl programmers, this does NOT work like Perl's anonymous-list technique. It will
discard any elements on the right hand side that do not have a corresponding recipient value on the
left hand side.
In Perl, you can put an array at the end of the list, and it will pick up all remaining elements
from the right hand of the assignment.
($val1,$val2,@others)=array("a","b","c","d","e")
will result in $val1="a", $val2="b", and
@others=("c","d","e").
This cannot seem to be done in PHP, even if you declare the array beforehand:
$others=Array();
list($val1,$val2,$others)=array("a","b","c","d","e")
will result in $val1="a", $val2="b", and $others="c". Note also that
$others is redefined as whatever type the right-hand side value was, and is no longer an Array.
This is in 4.3.11.
----
Manual Page -- http://www.php.net/manual/en/function.list.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52802
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52802&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52802&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52802&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52802&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52802&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52802&report=yes
Search -- http://master.php.net/manage/user-notes.php