Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function vnos_v_tabelo()
- {
- for($i=0,$t=array();$i<20;$i++)
- {
- $t[]=rand(10,50);
- }
- print_r($t);
- return $t;
- }
- function prepis($t)
- {
- $t1 = array();
- foreach ($t as $i => $x) {
- if($i%2!=0)
- {
- if($t[$i]%2!=0)
- {
- $t1[]=$t[$i];
- }
- else
- $t1[]='x';
- }
- else
- $t1[]='x';
- }
- print_r($t1);
- return $t1;
- }
- function izpis($t,$t1)
- {
- echo "<table border = solid width = 600px ><caption>Prva tabela</caption><tr>";
- foreach ($t as $i => $x)
- {
- echo "<td >".$x."</td>";
- }
- echo "<table border = solid width = 600px ><caption>Druga tabela</caption><tr>";
- foreach ($t1 as $i => $x)
- {
- if($x != 'x')
- {
- echo "<td id='red'>".$x."</td>";
- }
- else
- {
- echo "<td >".$x."</td>";
- }
- }
- }
- $t = vnos_v_tabelo();
- $t1 = prepis($t);
- izpis($t,$t1);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement