Page 1 of 1

Open files in sequence

Posted: Thu Oct 03, 2019 9:57 pm
by KimmoFrye
Hi,

I need to open some files in sequence and get them data. Can you please show how to open a list of files from a folder via loop? How do I reference a specific item in the array based on loop step?

Re: Open files in sequence

Posted: Thu Oct 03, 2019 10:30 pm
by support
Example on PHP:

Code: Select all

// get all files in a folder - $folder_path
$all_items = $folder->get_all_items($folder_path,true, false);
// get all items to array
$all_items=explode("<br>",$all_items);
// print array elements in the debug panel
print_r($all_items);

// cycle through all files in a folder
foreach ($all_items as $value)
{
	// get file name
        $name = $file_os->get_name(trim($value));
        // get file data
        $data = $textfile->read_file(trim($value));
}
or

Code: Select all

// get all files in a folder - $folder_path
$all_items = $folder->get_all_items($folder_path,true, false);
// get all items to array
$all_items=explode("<br>",$all_items);
// print array elements in the debug panel
print_r($all_items);

// cycle through all files in a folder
for($i=0; $i<count($all_items);$i++)
{
	// get file name
        $name = $file_os->get_name(trim($all_items[$i]));
        // get file data
        $data = $textfile->read_file(trim($all_items[$i]));
}

Re: Open files in sequence

Posted: Thu Oct 03, 2019 11:05 pm
by KimmoFrye
Thanks so much for examples!