Transform an array

Take your time, follow the code and check your understanding.

The codePHP arrays and requests
<?php
$values = [1, 2, 3];
$result = array_map(fn($n) => $n * 2, $values);
echo json_encode($result);
Your answer4 min · no timer
What will the code print?

Show solution and explanation

array_map returns a new array of callback results. Each number is multiplied by two, and json_encode serialises that array.

[2,4,6]