Skip to content

Instantly share code, notes, and snippets.

@bxt
Created February 26, 2011 15:22
Show Gist options
  • Save bxt/845295 to your computer and use it in GitHub Desktop.
Save bxt/845295 to your computer and use it in GitHub Desktop.
Accessing a var by ternary operator condition in PHP
<?php $var="foo"; $foo=array(); ${true?$var:"bar"}[]=$var; var_dump($foo);
/* Output:
array(1) {
[0]=>
string(3) "foo"
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment