Jump to content

select files in folder which begin with $ID = 1


web_master

Recommended Posts

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 ...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.