Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Moduł tagów
djgarsi
post
Post #1





Grupa: Zarejestrowani
Postów: 459
Pomógł: 26
Dołączył: 1.06.2009

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


Witam. Jestem w trakcie pisania modułu dla pewnego serwisu. Jest to moduł tagów.
Oto mój kod który niby działa, lecz nie do końca:
  1. <?php
  2.  
  3. $string = "jakis super fajnie dlugi ciag znakow.";
  4.  
  5. $string = preg_replace('#[.,)(!]+#', '', $string);
  6. $text = explode(' ', $string);
  7. $words = array();
  8. $len = 0;
  9.  
  10. foreach ($text as $str) {
  11. $word = preg_replace('#[^a-ż]+#i', '', $str);
  12. if (mb_strlen($word) > 0) {
  13. $words[] = $word;
  14. $len += mb_strlen($word);
  15. }
  16. }
  17.  
  18. echo'Tagi: ';
  19.  
  20. for($i=0;$i<=$len;$i++)
  21. {
  22. echo '<a href="/tagi/'.$words[$i].'.html">'.$words[$i].'</a> ';
  23. }
  24.  
  25. ?>


A oto wyświetlane błędy:
Kod
Notice: Undefined offset: 8 in D:\Serwer\www\index.php on line 23
Notice: Undefined offset: 8 in D:\Serwer\www\index.php on line 23
Notice: Undefined offset: 9 in D:\Serwer\www\index.php on line 23
Notice: Undefined offset: 9 in D:\Serwer\www\index.php on line 23
Notice: Undefined offset: 10 in D:\Serwer\www\index.php on line 23
Notice: Undefined offset: 10 in D:\Serwer\www\index.php on line 23
Notice: Undefined offset: 11 in D:\Serwer\www\index.php on line 23
... itd.


Co robię źle w powyższym kodzie?

Ten post edytował djgarsi 17.02.2011, 10:36:33


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


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: 19.08.2025 - 23:59