Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <style>
- table{
- border-collapse: collapse;
- }
- table, td, th {
- border: 1px solid black;
- font-size: 40px;
- }
- </style>
- <?php
- function drawArray($vrstica, $stolpec, $maxV, $maxS, $vrednost, $background, $caption){
- if($vrstica == 0 && $stolpec == 0){
- echo "<table style='background-color:" . $background . ";'>";
- echo "<caption>" . $caption . "</caption>";
- }
- if($stolpec == 0)
- echo "<tr>";
- echo "<td style=' background-color:" . $background . "'>";
- echo $vrednost;
- echo "</td>";
- if($stolpec == $maxS-1)
- echo "</tr>";
- if($stolpec == $maxS-1 && $vrstica == $maxV-1)
- echo "</table>";
- }
- function compare($a, $b) {
- if ($a == $b) {
- return 0;
- }
- return ($a < $b) ? 1 : -1;
- }
- function izpisSort($tab, $textPrviS, $textDrugiS){
- $i = 0;
- uasort($tab, 'compare');
- drawArray(0,0,13,2,$textPrviS,"red","");
- drawArray(0,1,13,2,$textDrugiS,"orange","");
- foreach($tab as $key=>$value){
- drawArray($i+1,0,13,2,$key,"red","");
- drawArray($i+1,1,13,2,$value,"orange","");
- $i++;
- }
- }
- $temp1=array("jan"=>2.8, "feb"=>7.6, "mar"=>18.3, "apr"=>14.8, "maj"=>25.9,"jun"=>29.6,
- "jul"=>33.7,"aug"=>35.5, "sep"=>25.1, "okt"=>15.4, "nov"=>9.5, "dec"=>4.3);
- echo 'Prva tabela';
- izpisSort($temp1, "Mesec", "Temp");
- $temp2=array(
- "Ljubljana"=> array("jan"=>6.8, "feb"=>8.4, "mar"=>13.0, "apr"=>15.5, "maj"=>21.3,"jun"=>25.6,
- "jul"=>29.7,"aug"=>31.3, "sep"=>26.2, "okt"=>17.8, "nov"=>11.5, "dec"=>6.3),
- "Maribor"=> array("jan"=>2.8, "feb"=>7.6, "mar"=>18.3, "apr"=>14.8, "maj"=>25.9,"jun"=>29.6,
- "jul"=>33.7,"aug"=>35.5, "sep"=>25.1, "okt"=>15.4, "nov"=>9.5, "dec"=>4.3),
- "Koper"=> array("jan"=>6.8, "feb"=>9.6, "mar"=>13.4, "apr"=>17.0, "maj"=>24.6,"jun"=>31.6,
- "jul"=>34.7,"aug"=>35.3, "sep"=>26.2, "okt"=>14.2, "nov"=>9.0, "dec"=>3.1),
- "Piran"=> array("jan"=>5.7, "feb"=>6.6, "mar"=>9.6, "apr"=>12.3, "maj"=>22.9,"jun"=>26.5,
- "jul"=>32.2,"aug"=>31.1, "sep"=>25.1, "okt"=>20.4, "nov"=>16.5, "dec"=>10.3),
- "Ptuj"=> array("jan"=>4.8, "feb"=>6.9, "mar"=>12.7, "apr"=>16.3, "maj"=>22.4,"jun"=>27.1,
- "jul"=>31.4,"aug"=>32.8, "sep"=>24.3, "okt"=>18.4, "nov"=>12.5, "dec"=>2.3),
- "Kamnik"=> array("jan"=>3.8, "feb"=>5.9, "mar"=>13.5, "apr"=>17.2, "maj"=>23.3,"jun"=>26.3,
- "jul"=>30.5,"aug"=>32.1, "sep"=>24.6, "okt"=>17.1, "nov"=>11.2, "dec"=>5.5));
- foreach($temp2 as $key=>$value)
- $november[$key] = $value['nov'];
- // echo "<br>";
- // echo "Kraji od najhladnejsega do najtoplejsega, na osnovi podatkov za november." . "<br>";
- // echo "<br>";
- echo 'druga tabela';
- izpisSort($november, "Kraj", "Temp");
- foreach($temp2 as $key=>$value)
- $povp[$key] = array_sum($value)/count($value);
- //
- // echo "<br>";
- // echo "Kraji od najhladnejsega do najtoplejsega, na osnovi podatkov povprecne temperature." . "<br>";
- // echo "<br>";
- izpisSort($povp, "Kraj", "Povp temp");
- echo 'po tretji tabeli';
- ksort($povp);
- // echo "<br>";
- // echo "Kraji razvrsceni po abecedi." . "<br>";
- // echo "<br>";
- izpisSort($povp, "Kraj po abecedi", "Povp temp");
- echo 'po četrti tabeli';
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement