note 60393 added to function.array
| From: | relsqui at chiliahedron dot com | Date: | Thu, 05 Jan 2006 17:27:22 +0000 |
| Subject: | note 60393 added to function.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101258@lists.php.net to get a copy of this message | ||
Even though array() is a language construct, not a function, you can still use it to create
"anonymous" arrays. I found this to be a handy workaround for variable length argument
lists, which PHP doesn't support:
<?php
if (player_used(array('stick', 'string'))) {
echo "You put together a makeshift fishing pole and sit down on the pier.";
}
?>
If the above didn't work, I would have to initialize an array first, then pass that to the
function:
<?php
// NOT NECESSARY:
$a = array('stick', 'string');
if (player_used($a)) {
echo "You put together a makeshift fishing pole and sit down on the pier.";
}
?>
Then the function can just iterate through the array which is its single argument, as it would if it
had multiple arguments.
----
Manual Page -- http://www.php.net/manual/en/function.array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60393
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60393&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60393&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60393&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60393&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60393&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60393&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60393&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60393&report=yes
Search -- http://master.php.net/manage/user-notes.php