Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Jak pobrać rozszeżenie z pliku?
Madorecom
post
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 22.10.2004

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


Fukcja żeby wypisało mi jaki plik ma rozszezenie np .rar .exe itd...exclamation.gif
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


  1. <?php
  2.  
  3. /**
  4.  * Zwraca rozrzeżenie pliku
  5.  * @param string $strPath ścieżka pliku
  6.  * @return string rozszeżenie pliku
  7.  */
  8. function GetExt( $strPath )
  9. {
  10. $strFile = basename( $strPath );
  11. $arrTemp = explode( '.', $strPath );
  12. return '.' . $arrTemp[1];
  13. }
  14.  
  15. ?>
Go to the top of the page
+Quote Post
Madorecom
post
Post #3





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 22.10.2004

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


sad.gif A jak teraz wyswietlic tą koncówke z pliku przez echo ""; ?
Go to the top of the page
+Quote Post
mike
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


  1. <?php
  2. echo GetExt( 'C:katalogplik.php' );
  3. ?>

Kursy dla początkujących exclamation.gif!
Go to the top of the page
+Quote Post
Madorecom
post
Post #5





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 22.10.2004

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


Dzieki!! bardzo

jestem początkującym!
Go to the top of the page
+Quote Post
FiDO
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 1 717
Pomógł: 0
Dołączył: 12.06.2002
Skąd: Wolsztyn..... Studia: Zielona Góra

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


mike_mech: Twoj sposob wyklada sie gdy plik ma jakies kropki w nazwie.
Lepiej wiec bedzie tak:
  1. <?php
  2.  
  3. function GetExt( $strPath )
  4. {
  5. return '.' . end(explode(&#092;".\", basename($strPath)));
  6. }
  7.  
  8. ?>


--------------------
Brak czasu :/
Go to the top of the page
+Quote Post

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:44