Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] Array + file_get_contents ? - polskie znaki ?
-Gość-
post
Post #1





Goście







Witam otuż tak próbowałem kilku sposóbów

  1. <?php
  2. function _no_pl($tekst)
  3. {
  4.  $tabela = Array(
  5.  //WIN
  6. "xb9" => "a", "xa5" => "A", "xe6" => "c", "xc6" => "C",
  7. "xea" => "e", "xca" => "E", "xb3" => "l", "xa3" => "L",
  8. "xf3" => "o", "xd3" => "O", "x9c" => "s", "x8c" => "S",
  9. "x9f" => "z", "xaf" => "Z", "xbf" => "z", "xac" => "Z",
  10. "xf1" => "n", "xd1" => "N",
  11.  //UTF
  12. "xc4x85" => "a", "xc4x84" => "A", "xc4x87" => "c", "xc4x86" => "C",
  13. "xc4x99" => "e", "xc4x98" => "E", "xc5x82" => "l", "xc5x81" => "L",
  14. "xc3xb3" => "o", "xc3x93" => "O", "xc5x9b" => "s", "xc5x9a" => "S",
  15. "xc5xbc" => "z", "xc5xbb" => "Z", "xc5xba" => "z", "xc5xb9" => "Z",
  16. "xc5x84" => "n", "xc5x83" => "N",
  17.  //ISO
  18. "xb1" => "a", "xa1" => "A", "xe6" => "c", "xc6" => "C",
  19. "xea" => "e", "xca" => "E", "xb3" => "l", "xa3" => "L",
  20. "xf3" => "o", "xd3" => "O", "xb6" => "s", "xa6" => "S",
  21. "xbc" => "z", "xac" => "Z", "xbf" => "z", "xaf" => "Z",
  22. "xf1" => "n", "xd1" => "N");
  23.  
  24.  return strtr($tekst,$tabela);
  25. }
  26. $result = _no_pl($result);
  27. ?>


Zwraca mi : Notice: Array to string conversion ... on line 27

27 linijka to :
  1. <?php
  2. return strtr($tekst,$tabela);
  3. ?>


Jakieś pomysły może macie ?
Go to the top of the page
+Quote Post
l0ud
post
Post #2





Grupa: Zarejestrowani
Postów: 1 387
Pomógł: 273
Dołączył: 18.02.2008

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


co przekazujesz tej funkcji pod zmienną $result ? To musi być ciąg, nie tablica. U mnie Twój kod nie generuje żadnych ostrzeżeń, o ile podam mu właściwy typ zmiennej...
Go to the top of the page
+Quote Post
-Gość-
post
Post #3





Goście







  1. <?php
  2. $data = file_get_contents("http://www.adres.pl/szukaj.php?co=$szukaj") or die("blad");
  3. preg_match_all('/<a href=\"(.*)/strona/(.*)/(.*)\">(.*)</a>/', $data, $result);
  4. ?>
Go to the top of the page
+Quote Post
-Gość-
post
Post #4





Goście







I chcę tylko tytuł linka

Mam np tytuł : Nic siÄ� nie staĹ�o

Robię tak :

  1. <?php
  2. $result[4][$i] = str_replace("Ä", "e", $result[4][$i]);
  3. ?>


To mi zamieni i będzie to wyglądać Nic sie? nie staĹ�o
Ale ja niechcę wgl. mieć krzaczków (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
l0ud
post
Post #5





Grupa: Zarejestrowani
Postów: 1 387
Pomógł: 273
Dołączył: 18.02.2008

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


Twoja funkcja pobiera tylko string, a preg_match_all zwraca tablicę. Musisz po prostu użyć swojej funkcji w pętli dla poszczególnych elementów $result .
Go to the top of the page
+Quote Post
-Gość-
post
Post #6





Goście







dzięki.
Go to the top of the page
+Quote Post

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 - 10:52