3 ms·
Just wait until you meet dynamic dynamic variables, nothing more elegant than that... $x=0;$a='x';$b='a'; echo $$$b;
by mattigames 8y ago
Just wait until you meet dynamic dynamic variables, nothing more elegant than that...
$x=0;$a='x';$b='a'; echo $$$b;
- duncan-donuts 8y agoHaven’t seen that one in the wild. Can that chain just keep going?!
- arkh 8y agoLazy coder here : foreach(['a' => closureA, 'b' => closureB, 'c' => closureC] as $name => $toApply) { $myObject->${convertNameToFieldName($name)} = $toApply($something); }
- Piskvorrr 8y agoToo clever by half - a textbook example. This is, in essence, write-only code.