Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] tylko jeden rekord..., jak go wyświetlić - zidentyfikować
shpaque
post
Post #1





Grupa: Zarejestrowani
Postów: 651
Pomógł: 3
Dołączył: 31.01.2011
Skąd: Warszawa

Ostrzeżenie: (10%)
X----


Witam ponownie, mój kod wygląda następująco:

  1. <?
  2. $dateins = array();
  3. $dateouts = array();
  4. $titles = array();
  5. $citys = array();
  6. $streets = array();
  7. $poolnames = array();
  8. $poollengths = array();
  9. $count = 0;
  10. $teraz = time();
  11. $database = './db/zawody.db';
  12. $items = file($database);
  13.  
  14. foreach($items as $line)
  15. {
  16. list($datein, $dateout, $title, $city, $street, $poolname, $poollength) = explode('|', trim($line));
  17. $dateins[$count] = $datein;
  18. $dateouts[$count] = $dateout;
  19. $titles[$count] = $title;
  20. $citys[$count] = $city;
  21. $streets[$count] = $street;
  22. $poolnames[$count] = $poolname;
  23. $poollengths[$count] = $poollength;
  24.  
  25. if ($teraz < strtotime($datein))
  26. {
  27. $difference = $teraz - strtotime($dateins[$count]);
  28. echo $difference;
  29. echo $titles[$count];
  30. echo $citys[$count];
  31. }
  32. $count++;
  33. }
  34. ?>


Wyświetla mi dzięki temu wpisy późniejsze niż bieżąca data - a jak zrobić, żeby wyświetlił mi tylko najbliższy termin? Albo następny od najbliższego?
Generalnie chyba najlepiej zrobić coś takiego że by wyświetlił mi tylko rekord gdzie zmienna $difference jest najbliższa "0" - ale jak to zrobić i jak zrobić żeby naprzykład wyświetlić drugą z kolei lub 5 z kolei od godziny "zero"?

Ten post edytował shpaque 3.12.2013, 18:26:23
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: 25.08.2025 - 09:23