logo CodeStepByStep logo

array_mystery8

Language/Type: PHP array mystery arrays

Consider the following function:

function array_mystery8($arr) {
    for ($i = 0; $i < count($arr); $i++) {
        $n = $arr[$i];
        if ($n % 10 == 0) {
            array_splice($arr, $i, 1);
            array_push($arr, $n);
        }
    }
    return $arr;
}

For each array below, indicate what the returned array's contents would be after the function array_mystery8 were called and passed that array as its parameter.

[1, 20, 3, 40]
[80, 3, 40, 20, 7]
[40, 20, 60, 1, 80, 30]

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.