Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [txt&php] wczytywanie i zapisywanie danych w pliku
matiszostak
post
Post #1





Grupa: Zarejestrowani
Postów: 116
Pomógł: 0
Dołączył: 6.07.2006
Skąd: z ml2.cba :)

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


jak w temacie jak mozna zrobic (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) zeby jest plik o nazwie dane.txt i zawiera on np:

[kod]id|pole2|pole3|pole4[/kod] i plik ktory na strone wczytuje linijke o danym "id" jak to zrobic (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)

Ten post edytował matiszostak 11.09.2006, 13:01:18
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Hacker
post
Post #2





Grupa: Zarejestrowani
Postów: 225
Pomógł: 0
Dołączył: 1.11.2005

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


Cytat
dalej mi nie dziala


Hmmm...
Patrząc na twój test działa...

Ad. 1 tzn. 5 kolejnych id?? Jak tak to
  1. <?php
  2. function pobierz($id)
  3. {
  4. $baza = @fopen ('/baza.txt', 'r');
  5. $result = false;
  6. if (!is_array($id))
  7. $id = array(strval($id));
  8. if ($baza)
  9. {
  10. while (!feof($baza))
  11. {
  12. if (count($result) == count($id))
  13. break;
  14. $string = fgets($baza);
  15. if (in_array($id, $substr = substr($string, 0, strpos($string, '|'))))
  16. $result[$substr] = $string;
  17. }
  18. }
  19. return $result;
  20. }
  21. ?>


Ad. 2.
fwrite()(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)

Ten post edytował Hacker 16.09.2006, 18:17:37
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: 4.10.2025 - 15:03