Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $arr = array();
- for($i = 0; $i < 100000; ++$i) {
- $arr[$i] = (rand() % 2 === 0 ? '0' : '1');
- }
- $t1 = microtime();
- for($i = 0; $i < 100000; ++$i) {
- $arr[$i] = '1' & $arr[$i];
- }
- echo microtime() - $t1;
- echo "\n";
- $t1 = microtime();
- for($i = 0; $i < 100000; ++$i) {
- if($arr[$i] == '1')
- $arr[$i] = '1';
- else
- $arr[$i] = '0';
- }
- echo microtime() - $t1;
Advertisement
Add Comment
Please, Sign In to add comment