Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     class nowa
  4.     {
  5.     public $adres,$nazwisko,$imie;
  6.     public $osoby = Array(
  7.         array("Imie" => "","Nazwisko" => "","Adres" => ""),
  8.         array("Imie" => "","Nazwisko" => "","Adres" => ""),
  9.         array("Imie" => "","Nazwisko" => "","Adres" => "")
  10.     );
  11.    
  12.     public function dodajOsobe($index,$imie,$nazwisko,$adres)
  13.         {
  14.             $this->osoby[$index]["Imie"] = $imie;
  15.             $this->osoby[$index]["Nazwisko"] = $nazwisko;
  16.             $this->osoby[$index]["Adres"] = $adres;
  17.         }
  18.    
  19.     public function dejWszystkich() {
  20.         for($i = 0; $i < count($this->osoby); $i++) {
  21.             echo $this->osoby[$i]["Imie"] . " " . $this->osoby[$i]["Nazwisko"] . " " . $this->osoby[$i]["Adres"] . "<br>";
  22.         }
  23.     }
  24.     }
  25.     $grupaA = new nowa();
  26.     $grupaB = new nowa();
  27.    
  28.     $grupaA->dodajOsobe(0,"Przemek","Róg","Dom");
  29.     $grupaA->dodajOsobe(1,"Jarek","Róg","Ten sam dom");
  30.     $grupaA->dodajOsobe(2,"Patryk","Tylec","Nie wiem");
  31.    
  32.     $grupaB->dodajOsobe(0,"Damian","Kuseks","Dom");
  33.     $grupaB->dodajOsobe(1,"Mejzuro","Adamo","Inny dom");
  34.     $grupaB->dodajOsobe(2,"Adriano","Kozioło","Jeszcze inny dom");
  35.    
  36.     $grupaA->dejWszystkich();
  37.     echo "<br>";
  38.     $grupaB->dejWszystkich();
  39.    
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement