Answers for "php apply function to array elements"

PHP
0

php apply function to array elements

<?php
function cube($n)
{
    return ($n * $n * $n);
}

$a = [1, 2, 3, 4, 5];
$b = array_map('cube', $a);
print_r($b);
?>
Posted by: Guest on February-23-2021

Code answers related to "php apply function to array elements"

Browse Popular Code Answers by Language