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?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.