<?php
//////////apply this fuction to all values of input array
function cube($n)
{
return($n * $n * $n);
}
$a = array(1, 2, 3, 4, 5);
$b = array_map("cube", $a);
print_r($b);
code 2
//////////////////////////// return an array with all values of input array > 2
function fuv($n)
{
if($n>2) {
return true;
}
}
$c=array_filter($a,"fuv");
print_r($c);
No hay comentarios:
Publicar un comentario