Re: Return an Array and immediately reference an index
| From: | Daniel Kolbo | Date: | Sat, 12 Apr 2008 16:57:44 +0000 |
| Subject: | Re: Return an Array and immediately reference an index | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-272939@lists.php.net to get a copy of this message | ||
Casey wrote:
On Sat, Apr 12, 2008 at 9:35 AM, Nathan Nobbe <quickshiftin@gmail.com> wrote:Just awesome! Thanks for the explanation Casey, and thanks for the archived link Nathan. I knew I'd learn something by asking.On Sat, Apr 12, 2008 at 12:18 PM, Casey <heavyccasey@gmail.com> wrote:<?php echo ${!${!1}=ReturnArray()}['a']; ${!${!1}=ReturnArray()}['a'] !1 resolves to false. ${!${false}=ReturnArray()}['a'] false resolves to... I don't know. Let's just say false resolves to "a". ${!$a=ReturnArray()}['a'] $a is now the array. The ! changes the returned array into the boolean false (like: if (!$handle = fopen('x', 'r')) { echo 'connection failed' }. ${false}['a'] I don't know what false resolves to, but we're using "a". $a['a'] ?>On Sat, Apr 12, 2008 at 9:12 AM, Nathan Nobbe <quickshiftin@gmail.com>wrote:'j');On Fri, Apr 11, 2008 at 6:33 PM, Daniel Kolbo <kolb0057@umn.edu> wrote: search the archives ;) http://www.mail-archive.com/php-general@lists.php.net/msg224626.html -nathan<?php function ReturnArray() { return array('a' => 'f', 'b' => 'g', 'c' => 'h', 'd' => 'i', 'e' =>} echo ${!${!1}=ReturnArray()}['a']; // 'f' ?>ya; i never did sit down and try to figure out how that works; care to explain ? -nathan