Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="lt">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Forma</title>
- </head>
- <body>
- <h2>1 užd : Vidurkiai</h2>
- <?php
- arba $metai = array(
- "Pavasaris" => array(
- "Kovas" = rand(-2 ,15 ),
- "Kovas" = rand(-2 ,15 ),
- "Kovas" = rand(-2 ,15 ),
- ),
- "Pavasaris" => array(
- "Kovas" = rand(-2 ,15 ),
- "Kovas" = rand(-2 ,15 ),
- "Kovas" = rand(-2 ,15 ),
- ),
- "Pavasaris" => array(
- "Kovas" = rand(-2 ,15 ),
- "Kovas" = rand(-2 ,15 ),
- "Kovas" = rand(-2 ,15 ),
- ),
- "Pavasaris" => array(
- "Kovas" = rand(-2 ,15 ),
- "Kovas" = rand(-2 ,15 ),
- "Kovas" = rand(-2 ,15 ),
- ),
- )
- ir :
- foreach metai as season => seasonVal
- foreach metai[season] as month => mVal
- if mVal>=10 {
- echo month, mVal
- }
- _____________________________
- $pavasaris = rand(-2 ,15 );
- $ruduo = rand(10 ,-2 );
- $vasara = rand(15 ,35 );
- $ziema = rand(-30 ,0 );
- $vidurkis = array(
- "Pavasaris" => $pavasaris,
- "Ruduo" => $ruduo,
- "Vasara" => $vasara,
- "Žiema" => $ziema,
- );
- foreach ($vidurkis as $key => $val) {
- echo ''.$key.' : '.$val.' ,';
- }
- echo '<hr>';
- foreach ($vidurkis as $key => $val) {
- if($val > 10 ) {
- echo ''.$key.' : '.$val.' , ';
- }
- }
- ?>
- <h2>2 užd : Matricos</h2>
- <?php
- $file = "DUOMENYS.txt";
- $content = file_get_contents($file);
- $content = str_replace("\n", " ", $content);
- $arr = explode(" ", $content);
- print_r($arr);
- $lines = $arr[0];
- $cols = $arr[1];
- $count = $lines * $cols;
- $randNum = rand(1,100);
- for ($i = 2; $i < $count + 2; $i++) {
- $arr[$i] *= $randNum;
- }
- echo "<br>";
- print_r($arr); // debug
- $result = "";
- $index = 2;
- for ($y = 0; $y < $lines; $y++) {
- for ($x = 0; $x < $cols; $x++) {
- $result .= $arr[$index++] . " ";
- }
- $result .= "\r\n";
- }
- file_put_contents("rezultatai.txt", $result);
- ?>
- <h2>3 užd: Autos</h2>
- <?php
- $data = array(
- "Ford" => array (
- "Focus" => 1996,
- "Hocus" => 2019,
- "Pocus" => 1997
- ),
- "Audi" => array (
- "A6" => 2006,
- "A69" => 2020,
- "B20" => 1936
- ),
- "Lamborghini" => array (
- "Gallardo" => 2001,
- "Ballardo" => 1950,
- "Ricardo" => 2010
- ),
- "Volkswagen" => array (
- "Golf" => 2013,
- "Colf" => 2014,
- "Cholf" => 1984
- )
- );
- foreach ($data as $mark => $markVal) {
- krsort($data[$mark]);
- }
- echo "<pre>";
- print_r($data);
- echo "</pre>";
- $result = "";
- foreach ($data as $mark => $markVal) {
- foreach ($data[$mark] as $model => $modelVal) {
- if ($modelVal >= 2008) {
- $result .= $mark." ".$model." ".$modelVal;
- $result .= "\r\n";
- }
- }
- }
- echo $result;
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement