<?php
$directory = "/jobops";
$contents = scandir($directory);
if ($contents) {
foreach($contents as $key => $value) {
if ($value == "." || or $value == "..") {
unset($key);
}
}
}
echo "<ul>";
foreach($contents as $k => $v) {
echo "<li><a href=\"$directory/" . $v . "\">link text</a></li>";
}
echo "</ul>";
?>
Çalışmalıdır. , Dizin alır tarar, bir dizi $contents
("." Ve "..") göreceli adresler kaldırır ve sonra onları yankıları içine tüm dosya adlarını eşler.
, foreach
olsa, nispeten pahalı olduğunu unutmayın böylece isteyebilirsiniz basitçe unset $contents[0]
ve $contents[1]
.
Edited in response to the following (from the OP):
Warning:
scandir(www.markonsolutions.com/jobops)
[function.scandir]: failed to open
dir: No such file or directory in
/home/content/t/i/m/timhish/html/test.php
on line 5 Warning: scandir()
[function.scandir]: (errno 2): No such
file or directory in
/home/content/t/i/m/timhish/html/test.php
on line 5 Warning: Invalid argument
supplied for foreach() in
/home/content/t/i/m/timhish/html/test.php
on line 15 I changed ti from "/jobops"
thinking it was a relative directory
thing but apparently that's not it. also
im not sure what the
/home/content....... thing is but i am
currently hosted with go daddy maybe
thats how they store things?
$directory
değişken komut dosyası çağrıldığını nerede göredir. O should Benim için, $directory = "jobops"
klasörü ve komut aynı yerde saklanır varsayarak olabilir, bu nedenle benim durumumda, bu kök klasörden çalışır. Lütfen sunucunun dizin yapısı bilmeden Gerçekten sana yardım edemem, ama scandir()
fonksiyonu ile bir sorunu iktidar öneririm.
Bunu yapmak script ne gibi denilen aynı dizinde bir klasör oluşturun, en azından bir görüntü ile doldurmak için (ki böylece if()
unset tüm dizi değil takip) ve görmek eğer çalışır. O does o zaman klasörüne göreli yolu bulma ile sıkışmış iseniz. O doesn't sonra kendimi sıkışmış ediyorum eğer.