logo CodeStepByStep logo

collection_mystery0

Language/Type: PHP Queue collections collection mystery

What is the output of the following code? Note: Assume that print_helper($arr) prints a collection in the of a comma-separated array surrounded by [] brackets. A queue prints in [front ... back] order.

$queue = [];
for ($i = 1; $i <= 6; $i++) {
    array_push($queue, $i);
}                             

for ($i = 0; $i < count($queue); $i++) {
    print(array_shift($queue) . " ");
}
print(print_helper($queue) . " size " . count($queue));
Output:

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.