Nathan Rixham wrote: > Nathan Nobbe wrote: >> On Thu, Feb 28, 2008 at 6:14 PM, Nathan Rixham <nrixham@xxxxxxxxx> wrote: >> >>> if I show you guys how to do this: >>> >>> echo sillyFunc()['a'] . PHP_EOL; >>> >>> using a few brackets and things do you promise not to laugh? >>> *it's a bit weird* >> >> >> id like to see it. >> >> -nathan >> > > don't say I didn't warn ya fellow nathan! > > #!/usr/bin/php > <?php > function sillyFunc() { > return array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e'=>'some > string'); > } > > echo !${~${''}='sillyFunc'}=&${''}().${~${''}}['e'] . PHP_EOL; > > --- output --- > some string > > > To make things a little weirder yet here's the var's lol: > > print_r(get_defined_vars()); > > [] => sillyFunc > [¹] => Array > ( > [a] => 1 > [b] => 2 > [c] => 3 > [d] => 4 > [e] => some string > ) > > > to reference the var holding "string sillyFunc" (any of): > echo ${''}; echo ${NULL}; echo ${FALSE}; > > to reference our array [¹] (yeah it is called ¹) > print_r(${~${''}}); > > > here's a quick simplification + alternatives. > > echo (!$array = sillyFunc()),$array['e']; > echo (!$array = sillyFunc()).$array['e']; > > and a useful ternary one: > echo is_array($array = sillyFunc()) ? $array['e'] : ''; > > > told you it was a bit weird [took me a couple hours to figure out]! > > nath :) ROFLMAO, ha ha ha ha ha ha ha ha hoo ha ha ha ha ha hooo haaa! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php