3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function dlzka_rurok($miestnost_w, $miestnost_h, $rozostup) { $dlzka = 0; $dlhsie = ($miestnost_w>$miestnost_h? $miestnost_w: $miestnost_h); for($i=1; $i < ($dlhsie/($rozostup*2)); $i++) { $dlzka += $miestnost_w-($i*($rozostup*2)); $dlzka += $miestnost_h-($i*($rozostup*2)); } return ($dlzka*2); } $miestnosti = array( "Izba E" => array(375, 350, 10), "Izba D" => array(375, 362, 10), "Kupelka" => array(183, 248, 10), "Predsien" => array(184, 228, 15), "Kuchyna" => array(200, 350, 15), "Stredna obyvacka" => array(250, 400, 15), "Obyvacka" => array(200, 400, 10) ); $celkova_dlzka = 0; foreach($miestnosti as $key => $value) { $aktualna_dlzka = dlzka_rurok($value[0], $value[1], $value[2]); $celkova_dlzka += $aktualna_dlzka + 6; echo $key.": ".($aktualna_dlzka/100)."m, "; } echo "Celkova dlzka rurok v dome: ".($celkova_dlzka/100)."m (cena PEX-AL-PEX 16x2: ".round((($celkova_dlzka/100)*(0.54*1.2)), 2)." EUR / 20x2: ".round((($celkova_dlzka/100)*(0.85*1.2)), 2)." EUR)";
Output for 4.3.0 - 7.1.0
Izba E: 124.2m, Izba D: 128.52m, Kupelka: 41.04m, Predsien: 24.08m, Kuchyna: 41.8m, Stredna obyvacka: 59.8m, Obyvacka: 76m, Celkova dlzka rurok v dome: 495.86m (cena PEX-AL-PEX 16x2: 321.32 EUR / 20x2: 505.78 EUR)