Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Usuwanie linków z pliku txt
AlphaTester
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 20.12.2013

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


Cześć.
W jaki sposób mogę usunąć linki z pliku txt które nie mają w sobie na przykład znaku = ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
kujol
post
Post #2





Grupa: Zarejestrowani
Postów: 324
Pomógł: 27
Dołączył: 21.07.2013

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


Powinno pomóc (IMG:style_emoticons/default/wink.gif)

forum.php.pl/lofiversion/index.php/t24017.html + preg_match()

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





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 20.12.2013

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


Cytat(kujol @ 2.01.2014, 20:04:44 ) *
Powinno pomóc (IMG:style_emoticons/default/wink.gif)

forum.php.pl/lofiversion/index.php/t24017.html + preg_match()


Nie do końca..
Pokaże Ci przykład.

mam powiedzmy 4 linki w pliku link.txt

http://forum.php.pl/index.php
http://forum.php.pl/index.php?act=
http://forum.php.pl/index.php
http://forum.php.pl/index.php?act=

Problem polega na tym, ze nie wiem właśnie jak odfiltrować plik w ten sposób żeby zostały same http://forum.php.pl/index.php?act=
Rzecz w tym że próbowałem już unset, lecz w żaden sposób nie chce mi to działać.



Dobra, chwila, wpadłem na pomysł dzięki wam jak mogę to napisać.
A teraz dajcie mi moje 5minut (IMG:style_emoticons/default/tongue.gif)

Na przyszłość dla ludzi borykających się z tym problemem co ja (IMG:style_emoticons/default/biggrin.gif)

  1.  
  2. <?php
  3. $file = file('linki.txt');
  4. $searchWord = '=';
  5. for($i = 0; $i <= count($file) - 1; $i++)
  6. {
  7.  
  8. if(strpos($file[$i], $searchWord) != false)
  9. {
  10. echo $file[$i]."\n";
  11. }
  12. }
  13. ?>
  14.  
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: 8.10.2025 - 18:51