Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Problem z zapisaniem tablicy do pliku
-Qechua-
post
Post #1





Goście







Mam coś takiego:


  1. $rob = array_unique($rob);
  2. foreach ($rob as $tt) {
  3. $aResults[] = array( "id"=>0,"value"=>$tt);
  4.  
  5. $string = implode("\n",$aResults);
  6. $handle = fopen("tmp/pl.txt", "w");
  7. fwrite($handle,$string);
  8. fclose($handle);
  9. }


Plik co prawda zapisuje do pliku, ale tylko:

Array
Array
Array
Array
Array
Array
Array
Array
Array
Array


Próbowałem zamienić:

  1. $string = implode("\n",$aResults);

na
  1. $string = implode("\n",$aResults['value']);

itd, ale w takim wypadku nic nie zapisuje.

Co robię źle ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





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




No bo za kazdym razem nadpisujesz zawartosc pliku. NIe nadpisuj a dopisuj. Otworz plik z własciwym atrybutem.

A w ogóle ja to bym dał poza pętlą i juz:
  1. file_put_contents('jakisplik.txt',print_r($aResults,true));

I juz
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: 6.10.2025 - 04:09