note 60393 deleted from function.array by nlopess
| From: | nlopess@php.net | Date: | Thu, 05 Jan 2006 19:09:09 +0000 |
| Subject: | note 60393 deleted from function.array by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-101266@lists.php.net to get a copy of this message | ||
Note Submitter: relsqui at chiliahedron dot com
Reason: useless
----
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.