Advertisement
stjan_kri

vaja8_2/3

Oct 20th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.  
  3.     function vnos_v_tabelo()
  4.     {
  5.         for($i=0,$t=array();$i<20;$i++)
  6.         {
  7.             $t[]=rand(10,50);
  8.         }
  9.         print_r($t);
  10.         return $t;
  11.     }
  12.  
  13.     function prepis($t)
  14.     {
  15.         $t1 = array();
  16.         foreach ($t as $i => $x) {
  17.             if($i%2!=0)
  18.             {
  19.                 if($t[$i]%2!=0)
  20.                 {
  21.                     $t1[]=$t[$i];
  22.                 }
  23.                 else
  24.                     $t1[]='x';
  25.             }
  26.             else
  27.                 $t1[]='x';
  28.         }
  29.        
  30.         print_r($t1);
  31.         return $t1;
  32.     }
  33.  
  34.     function izpis($t,$t1)
  35.     {
  36.         echo "<table border = solid width =  600px ><caption>Prva tabela</caption><tr>";
  37.         foreach ($t as $i => $x)
  38.         {
  39.             echo "<td >".$x."</td>";
  40.         }
  41.         echo "<table border = solid width = 600px ><caption>Druga tabela</caption><tr>";
  42.         foreach ($t1 as $i => $x)
  43.         {
  44.             if($x != 'x')
  45.             {
  46.                 echo "<td id='red'>".$x."</td>";
  47.             }
  48.             else
  49.             {
  50.                 echo "<td >".$x."</td>";
  51.             }
  52.         }          
  53.     }
  54.  
  55.  
  56.     $t = vnos_v_tabelo();
  57.     $t1 = prepis($t);
  58.     izpis($t,$t1);
  59.  
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement