Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> kasowanie rozszerzenia
juniors
post
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 15.09.2003
Skąd: zambrow

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


czy moze ktoś wie jak podczas podbierania nazywy plików z katalogu usunąc rozszerzenie?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
KaMeLeOn
post
Post #2





Grupa: Zarejestrowani
Postów: 680
Pomógł: 0
Dołączył: 1.10.2002
Skąd: Wrocław

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


[php:1:e3b86a5d3d]<?php
// ...
foreach ( $files AS $key => $value )
{
preg_match( $rexp, $value, $matches );
print rename( $path . $value, $path . $matches[1] ) . "n";
}
?>[/php:1:e3b86a5d3d]
preg_match() w pętli - tragedia...
Chyba że chcesz zażynać serwer... :?

Ja proponuje tak:
[php:1:e3b86a5d3d]<?php
$dir = './';
if( $handle = opendir($dir) )
{
while( false !== ( $file = readdir($handle) ) )
{
if($file != "." && $file != "..")
{
if( is_file($file) )
{
$tab = @explode('.', $file);
if( count($tab) > 1 )
{
$ext = array_pop($tab);
$filename = @implode('.', $tab);
echo 'Nazwa pliku: <b>' . $filename . '</b>, rozszerzenie: <b>' . $ext . "</b><br />rn";
}
else
{
echo 'Nazwa pliku: <b>' . $file . "</b><br />rn";
}
}
}
}
closedir($handle);
}
?>[/php:1:e3b86a5d3d]
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: 27.12.2025 - 10:06