Nedanstående filer finns i denna katalogen. Klicka på en fil för att visa dess innehåll.
dice6/
CDice.php CDiceSvg.php CHistogram.php FDice.php FHistogram.php common.php dice.php source.php template.php
<?php // =========================================================================================== // // FHistogram.php // // Description: Functions for a histogram // // Author: Mikael Roos // // ------------------------------------------------------------------------------------------- // // Returns a printable string, containing the key-value-pairs. // function histogramShowValues($anArray) { $s = ""; foreach($anArray as $key => $value) { $s .= "{$key} => {$value}<br />"; } return $s; } // ------------------------------------------------------------------------------------------- // // Calculate and return the average of the values. // function histogramAverage($anArray) { return array_sum($anArray) / count($anArray); } // ------------------------------------------------------------------------------------------- // // Calculate and return the average of the values. // function histogramPrint($anArray) { $res = Array(); // Calculate occurences for each key foreach($anArray as $key => $value) { @$res[$value] .= '*'; } ksort($res); return histogramShowValues($res); } ?>
. ..: © Mikael Roos, 2009