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?
Open files in sequence
Re: Open files in sequence
Example on PHP:
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
foreach ($all_items as $value)
{
// get file name
$name = $file_os->get_name(trim($value));
// get file data
$data = $textfile->read_file(trim($value));
}
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
Thanks so much for examples!