Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z array_search()
cuube
post
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 21.06.2006

Ostrzeżenie: (0%)
-----


Mam taki oto kod:

  1. <?php
  2. abstract class AbstractInstrument {
  3. private $name;
  4. private $category;
  5. private $instruments = array();
  6.  
  7. public function getName() {
  8. return $this->name;
  9. }
  10.  
  11. public function add (AbstractInstrument $instrument) {
  12. array_push ($this->instruments, $instrument);
  13. }
  14.  
  15. public function checkFamily() {
  16. $check = array_search($this->getName(), $this->instruments);
  17. if ($check === FALSE) { echo "brak"; } else { echo $check; }
  18. }
  19. }
  20. ?>


Dodaj sobie instrumenty itd. Tylko nie rozumiem dlaczego wywołując funkcje checkFamily() zawsze zwraca mi false - nawet jeśli istnieje w nim string z getName().

Z góry dzięki za pomoc.

Ten post edytował cuube 11.07.2008, 11:47:07
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 08:13