Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?php
$dir = "/papka/";
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if ($file != '.' && $file != '..' && filetype($dir.$file) == 'txt')
echo "$file <br>";
}
closedir($dh);
}
}
?>
<?php
$dir = "dir/";
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if ($file != '.' && $file != '..')
$filetype = end(explode(".",$file));
if ($filetype == "txt") echo $file."<br>";
}
closedir($dh);
}
}
?>
Просто не си махнал наклонените черти, а трябва :?:proba каза:...
Кой ти е казал да задаваш нещо, прочети ако трябва още няколко пъти мнението ми.proba каза:Кои наклонени черти не разбрах ?
Променливата я бях задал $dir = "dir/"; а папката се казва dir.
Не виждам кое не съм задал.
print_r(glob("dir/*.txt"));
Replace каза:Просто не си махнал наклонените черти, а трябва :?:proba каза:...
basename()kriss каза:а как да изведа само името на файла?
<?php
$dir = "dir/";
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if ($file != '.' && $file != '..')
$filetype = end(explode(".",$file));
$filename = $file;
$filename = str_replace(".$filetype","",$filename);
echo $filename.",";
}
closedir($dh);
}
}
?>
<?php
foreach ( glob("dir/*.txt") AS $file ) {
$pathinfo = pathinfo($file);
//print_r($pathinfo);
echo $pathinfo['filename'];
}
?>