Skip to content

Instantly share code, notes, and snippets.

@levonlee
Forked from phpfiddle/83c37cdd345c6d4f45342ac1a486d5d9.php
Last active August 29, 2015 14:24
Show Gist options
  • Save levonlee/b2d7634460c906d2f7d4 to your computer and use it in GitHub Desktop.
Save levonlee/b2d7634460c906d2f7d4 to your computer and use it in GitHub Desktop.
<?php
$condition = true;
$arr = array(
'a' => 'abc',
($condition ? 'b' : '') => ($condition ? '123' : ''),
($condition ? 'c' : '') => ($condition ? 'xyz' : ''),
);
$arr = array_filter($arr);
var_dump($arr);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment