Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
?>

Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #php #apply #function #array #elements
ADD COMMENT
Topic
Name
7+8 =