Jump to content

Recommended Posts

Hi,

 

how ca I load filenames and list them from folder which begin with nr-s

 

example: in folder are files:

 

1_file.doc

1_file.xls

1_file.ai

3_file.pdf

4_file.ai

 

how can I list only the files from folder wich begin with "1_"

 

thnxs

foreach (glob("1_*") as $file) {
    echo $file . " has a 1_ in it.<br />";
}

 

hm... Ill never use this...

 

If the files are in dir:  "advertise_files/"

 

how can I list files which begin with 1_ from this directory

 

Sorry, but I jus dont understand clearly how can I load the filenames and list them... :(

 

ummm are you serious?

 

<?php
$fileListDir = "advertise_files/1_*";
$fileList = glob($fileListDir);

echo "File list inside of " . $fileListDir . "<br />";

foreach ($fileList as $fileName) {
    echo $fileName . "<br />";
}
?>

 

That will display those files exactly how you requested it in the first post. glob read up on glob to modify it to your needs.

ummm are you serious?

 

<?php
$fileListDir = "advertise_files/1_*";
$fileList = glob($fileListDir);

echo "File list inside of " . $fileListDir . "<br />";

foreach ($fileList as $fileName) {
    echo $fileName . "<br />";
}
?>

 

That will display those files exactly how you requested it in the first post. glob read up on glob to modify it to your needs.

 

 

File list inside of advertise_files/1_*

 

only print this... :(

 

everything is OK but no print anything ... :(

 

no errors with:

error_reporting(E_ALL);

@ini_set('display_errors', '1');

Well try some variations, read the glob manual.

 

I have no clue where your script is located etc.

 

<?php
$fileListDir = "/advertise_files/1_*";
$fileList = glob($fileListDir);

echo "File list inside of " . $fileListDir . "<br />";

foreach ($fileList as $fileName) {
    echo $fileName . "<br />";
}
?>

 

That may work, or you may have to use other php items to get what you want like this:

<?php
$fileListDir = $_SERVER['DOCUMENT_ROOT'] . "/advertise_files/1_*";
$fileList = glob($fileListDir);

echo "File list inside of " . $fileListDir . "<br />";

foreach ($fileList as $fileName) {
    echo $fileName . "<br />";
}
?>

 

Or you may want to use relative paths. Come on and actually try some stuff for your self, who knows you may learn something by being adventurous.

  • 1 year later...

ummm are you serious?

 

<?php
$fileListDir = "advertise_files/1_*";
$fileList = glob($fileListDir);

echo "File list inside of " . $fileListDir . "<br />";

foreach ($fileList as $fileName) {
    echo $fileName . "<br />";
}
?>

 

That will display those files exactly how you requested it in the first post. glob read up on glob to modify it to your needs.

 

The Script works fine for me

thanks i wanted to know how to do this some time ago

 

btw Sorry for bumping the Topic ...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.