Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Plik tekstowy
integer000
post
Post #1





Grupa: Zarejestrowani
Postów: 129
Pomógł: 0
Dołączył: 24.09.2005

Ostrzeżenie: (30%)
XX---


  1. <?php
  2. $newsdata="news.dat";
  3.  
  4.  $table=file($newsdata);
  5.  
  6.  $total=count($table);
  7.  
  8.  $maxstron=ceil($total/1);
  9.  
  10.  if(!isset($_GET['idi'])) $_GET['idi']=1;
  11.  
  12.  $do=$_GET['idi']*1;
  13.  
  14.  $od=$do-1;
  15.  
  16.  if($do>$total) $do=$total;
  17.  
  18.  for ($iii=$od; $iii<$do; $iii++)
  19.  
  20.  {
  21.  
  22.  $data=explode("*|*", $table[$iii]);
  23.  
  24.  echo "<b>$data[0]</b><br>$data[1]<br><br><b>$data[2]</b>";
  25. };
  26. for($iii=1;$iii<=$maxstron;$iii++) echo "<a href="index.php?idi=$iii">$iii</a> | ";
  27. ?>


skrypt ten czyta plik od począdku do końca, a jak zrobić żeby było odwrotnie ? to znaczy żeby ostatni wpis w pliku tekstowym był wyświetlany jako pierwszy.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




  1. <?php
  2. //....
  3. $table=file($newsdata);
  4. $table = array_reverse($table);
  5. //....
  6. ?>


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Cysiaczek
post
Post #3





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Sugeruję utworzenie przyklejonego pt. "Jak odwrócić newsy do góry nogami". Ten temat jest poruszany bardzo cząsto.


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 21.08.2025 - 23:22