Open files in sequence

Ask questions here, report about problems.
Post Reply
KimmoFrye
Posts: 5
Joined: Tue Oct 01, 2019 9:16 pm

Open files in sequence

Post by KimmoFrye » Thu Oct 03, 2019 9:57 pm

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?

User avatar
support
Site Admin
Posts: 146
Joined: Fri Feb 22, 2019 3:42 pm

Re: Open files in sequence

Post by support » Thu Oct 03, 2019 10:30 pm

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]));
}

KimmoFrye
Posts: 5
Joined: Tue Oct 01, 2019 9:16 pm

Re: Open files in sequence

Post by KimmoFrye » Thu Oct 03, 2019 11:05 pm

Thanks so much for examples!

Post Reply