473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Verzeichnis auslesen

Hallo,

folgendes kleines Skript zeigt leider kein Ergebnis an:

<?PHP
function getImagesFromPath($path)
{
$result = array();

$handle=opendir($path);

while ($file = readdir ($handle))
{
if ($file != "." && $file != "..")
{
if (! is_dir($file))
{
$sub = substr($file, -4);
if ($sub == ".pdf")
$result[] = $file;
}
}
}

return $result;
}

$fileNames = getImagesFromPath("./data");
$num = count($fileNames);

for ($x=0;$x<$num;$x++)
{
echo "$fileNames[x]<br>";}

?>

Wenn ich aber folgendes verwende : echo "$filename[1]";
sehe ich den Inhalt von $filename.
Stimmt an der Schleife etwas nicht?

Gruß
Christoph Weis
Jul 17 '05 #1
1 1844
On 31 Jan 2004 09:51:13 -0800, c-****@web.de (Christoph Weis) wrote:
folgendes kleines Skript zeigt leider kein Ergebnis an:

<?PHP
function getImagesFromPath($path)
{
$result = array();

$handle=opendir($path);
You should check if this worked.

if (!$handle)
return FALSE; // or whatever is appropriate
while ($file = readdir ($handle))
Should be:

while (($file = readdir($handle)) !== FALSE)

Think of what happens if you get a file named "0" ?
{
if ($file != "." && $file != "..")
{
if (! is_dir($file))
{
$sub = substr($file, -4);
if ($sub == ".pdf")
$result[] = $file;
}
}
}

return $result;
}

$fileNames = getImagesFromPath("./data");
$num = count($fileNames);

for ($x=0;$x<$num;$x++)
{
echo "$fileNames[x]<br>";}
That should give a warning if you have error_reporting set high enough. You're
using 'x' as an array key - not the variable $x.

Presumably you mean:

echo $filenames[$x] . '<br>';

Or:

echo "{$filenames[$x]}<br>";

?>

Wenn ich aber folgendes verwende : echo "$filename[1]";
sehe ich den Inhalt von $filename.
Stimmt an der Schleife etwas nicht?


But there isn't a '$filename' variable anywhere in your post. There's
$fileNames though?

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: pekka niiranen | last post by:
Does anybody know Python recipe for changing the date of the directory or files in W2K to current date and time? In UNIX shell command "touch" does it. -pekka-
1
by: Peter Nikonevich | last post by:
Hallo! Ich habe eine Menudatei, die in alle Dateien eingebunden werden soll, die das menü anzeigen sollen. Die Menüdatei bindet ihrerseits 3 Javascript-Dateien ein die auf verschiedene...
1
by: Josef Buergi | last post by:
Hallo Ich möchte aus unserem Fileserver die Directorystruktur inkl Filenamen via ASP auslesen und diese in eine DB Tabelle eintragen. Der Webserver (IIS) läuft auf einem anderen Rechner. Ich...
5
by: haltestelle | last post by:
Hallo, ist es möglich rauszufinden auf welchen filesystem sich meine datei befindet ? zbsp. habe eine datei auf nen nfsserver liegen. es möchte ich gerne rausfinden, das die datei auf nen...
7
by: mike | last post by:
Hi, I am having difficulty in creating a thread using pthread_create. It seems that pthread_create does not execute 'program', and returns -1; I have checked the API but I am not sure why this...
1
by: Phane01 | last post by:
Hallo, ich habe eine Frage bezüglich des auslesens von Controls von Programmen. Ich schreibe an einem Programm, welches ein externes Tool starten soll. Das starten an sich ist kein Problem. In dem...
1
by: Phane01 | last post by:
Hallo, ich habe eine Frage bezüglich des auslesens von Controls von Programmen. Ich schreibe an einem Programm, welches ein externes Tool starten soll. Das starten an sich ist kein Problem. In dem...
1
by: marcel.stallmach | last post by:
Hallo, ich bin ehrlich schon am verzweifeln. Ich habe eine lokale Anwendung (Access) von wo aus eine HttpSendRequest an eine Website gesendet wird. Im HttpSendRequest werden die Daten per...
1
by: Robert Panther | last post by:
Hallo NG, habe eine Frage zur Verteilung von Anwendungen. Wenn ich eine ASP ..NET-Anwendung auf einem anderen Webserver einspielen will, muss ich dazu normalerweise ein eigenes virtuelles...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.