Question:Consider the following segment of code:
<?php
define("STOP_AT", 1024);
$result= array();
/* Missing code */
{
   $result[] = $idx;
}
print_r($result);
?>
What should go in the marked segment to produce the following array output? Array { [0] => 1 [1] => 2 [2] => 4 [3] => 8 [4] => 16 [5] => 32 [6] => 64 [7] => 128 [8] => 256 [9] => 512 } 

A foreach($result as $key => $val) 

B while($idx *= 2) 

C for($idx = 1; $idx < STOP_AT; $idx *= 2) 

D for($idx *= 2; STOP_AT >= $idx; $idx = 0) 

E while($idx < STOP_AT) do $idx *= 2 

+ Answer
+ Explanation
+ Report
Total Preview: 912

Copyright © 2024. Powered by Intellect Software Ltd