Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> problem z substr()
podziak
post
Post #1





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 10.09.2005

Ostrzeżenie: (20%)
X----


witam

mam cos takiego
  1. <a href="<? print $_SERVER['PHP_SELF'];?>?lang=de&<? echo substr($_SERVER['QUERY_STRING']."&lang=en",0,-8); ?>">PL</a>
  2. <a href="<? print $_SERVER['PHP_SELF'];?>?lang=de&<? echo substr($_SERVER['QUERY_STRING']."&lang=pl",0,-8); ?>">EN</a>


no i nie dziala tak jak nalezy bo chodzilo mi o wybor jezyka i przekazywanie linka ale po klikniecu na link PL jest ok ale jak pozniej klikne EN to wychodzi mi link takiej postaci "?lang=PL&lang=EN&..."
a chodz mi o to ze za kazdym kliknieciem pokazywal tylko jezyk

Ten post edytował podziak 8.07.2006, 10:32:29
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tiraeth
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

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


  1. <?php
  2. function httpd_query_builder ( $language = PL, $filename = $_SERVER['PHP_SELF'] )
  3. {
  4.  $httpdQuery = $filename;
  5.  if ( count($_GET) > 0 )
  6.  {
  7. foreach ( $_GET as $getKey => $getValue )
  8. {
  9.  if ( $getKey != 'lang' )
  10.  {
  11. $httpdQuery.= ( eregi('?', $httpdQuery) ) ? '&' : '?';
  12. $httpdQuery .= $getKey . '=' . $getValue;
  13.  }
  14. }
  15.  }
  16.  
  17.  
  18.  if ( $add != null )
  19.  {
  20. $httpdQuery .= ( eregi('?', $httpdQuery) ) ? '&lang=' : '?lang';
  21. $httpdQuery .= $language;
  22.  }
  23.  
  24.  return $httpdQuery;
  25. }
  26.  
  27. //
  28. //
  29. // Aktualnie adres to: blabla.php?lolek=25&lang=PL
  30. // Powinno zrobic tak:
  31. //
  32. echo httpd_query_builder(); // blabla.php?lolek=25&lang=PL
  33. echo httpd_query_builder('EN'); // blabla.php?lolek=25&lang=EN
  34. echo httpd_query_builder('EN', 'index.php'); // index.php?lolek=25&lang=EN 
  35. ?>


Pisane z palca, jak nie działa tzn. że powinno być coś w tym rodzaju (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
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: 10.10.2025 - 23:31