Created
December 11, 2013 01:39
-
-
Save TheFrozenFire/7903749 to your computer and use it in GitHub Desktop.
Array union experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$b = rand(0, 1); | |
$c = rand(0, 1); | |
for($i = 0; $i < 1000000; $i++) { | |
$a = ['foo' => 1]; | |
if($b) { | |
$a['bar'] = 2; | |
} | |
if($c) { | |
$a['baz'] = 3; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$b = rand(0, 1); | |
$c = rand(0, 1); | |
for($i = 0; $i < 1000000; $i++) { | |
$a = ['foo' => 1] | |
+ ($b?['bar' => 2]:[]) | |
+ ($c?['baz' => 3]:[]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment