note 103266 added to function.list
| From: | lili at nikha dot org | Date: | Mon, 04 Apr 2011 23:02:26 +0000 |
| Subject: | note 103266 added to function.list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178500@lists.php.net to get a copy of this message | ||
Keep it simple!
For associative arrays, my replacement for list() is this:
<?php
foreach ($associative_array as $key => $value) { $$key = $value; }
?>
Example:
<?php
$petnames = array();
$petnames['dog'] = 'Paul';
$petnames['cat'] = 'Lili';
foreach ($petnames as $name => $value) { $$name = $value; }
echo 'my pets are '.$dog.' and '.$cat;
?>
Will give you:
my pets are Paul and Lili
----
Server IP: 217.160.235.204
Probable Submitter: 87.123.72.203
----
Manual Page -- http://www.php.net/manual/en/function.list.php
Edit -- https://master.php.net/note/edit/103266
Del: integrated -- https://master.php.net/note/delete/103266/integrated
Del: useless -- https://master.php.net/note/delete/103266/useless
Del: bad code -- https://master.php.net/note/delete/103266/bad+code
Del: spam -- https://master.php.net/note/delete/103266/spam
Del: non-english -- https://master.php.net/note/delete/103266/non-english
Del: in docs -- https://master.php.net/note/delete/103266/in+docs
Del: other reasons-- https://master.php.net/note/delete/103266
Reject -- https://master.php.net/note/reject/103266
Search -- https://master.php.net/manage/user-notes.php