コード例 #1
0
ファイル: colander.php プロジェクト: netom/colander
function fMinNum($p)
{
    return function ($d) use($p) {
        return minNum($p, $d);
    };
}
コード例 #2
0
    foreach ($array as $a) {
        if (is_numeric($a)) {
            $sum += $a;
        }
    }
    return $sum;
}
function avgNum($array)
{
    return sumNum($array) / count($array);
}
for ($i = 0; $i < 20; $i++) {
    $numbers[] = rand(1, 10000);
}
dump($numbers);
echo "Min: " . minNum($numbers) . "<br>";
echo "Max: " . maxNum($numbers) . "<br>";
echo "Sum: " . sumNum($numbers) . "<br>";
echo "Average: " . avgNum($numbers) . "<br>";
$assoc = array("584291M" => "Alex Spiteri", "323423M" => "John Doe", "2323342G" => "Wenzu Mallia");
dump($assoc);
foreach ($assoc as $key => $value) {
    echo "<p>{$key}: {$value}</p>";
}
$nums = array();
for ($i = 0; $i < 10; $i++) {
    $nums[] = rand(1, 10000);
}
dump($nums);
rsort($nums);
dump($nums);