User Tools

Site Tools


uphp:functions:findnext

findnext

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Return next matching file information (after a findfirst)

Description

array findnext ( )

Continue a search to iterate through a list of files

Parameters

None

Return Values

Array of the next matching file containing the following keys and values:

KEYTYPEVALUE
filenamestringName of the file
attributesintFAT file attributes
filesizeintFile size in bytes
timestampintFAT timestamp of last save

Example

List details for all files and directories in the /logs directory

<pre><?
  chdir("/logs"); // change to the logs folder
  $arr=findfirst("*.*",255); // get the first entry matching any file or directory
  while ($arr) {
    print_r($arr);
    print("\r\n");
    $arr=findnext(); // get another matching file/directory
  }
?></pre>

Typical output for the above example (results vary depending on the contents of the /logs directory):

[$arr] = Array (
(string) [filename] => .
(int) [attributes] => 16
(int) [filesize] => 0
(int) [timestamp] => 1218599393
) 
[$arr] = Array (
(string) [filename] => ..
(int) [attributes] => 16
(int) [filesize] => 0
(int) [timestamp] => 1218599393
) 
[$arr] = Array (
(string) [filename] => ahcount.ini
(int) [attributes] => 32
(int) [filesize] => 570
(int) [timestamp] => 1248149344
) 
[$arr] = Array (
(string) [filename] => 2017
(int) [attributes] => 16
(int) [filesize] => 0
(int) [timestamp] => 1247484896
) 
[$arr] = Array (
(string) [filename] => log.txt
(int) [attributes] => 32
(int) [filesize] => 9888
(int) [timestamp] => 1248147596
) 
[$arr] = Array (
(string) [filename] => log_0.ini
(int) [attributes] => 32
(int) [filesize] => 517
(int) [timestamp] => 1248149344
) 
[$arr] = Array (
(string) [filename] => daily_kwh.csv
(int) [attributes] => 32
(int) [filesize] => 639
(int) [timestamp] => 1248133120
) 

Also See

findfirst() - Start searching the current folder for files matching a pattern and attributes

timefromfat() - Convert a FAT filetime to a Linux Timestamp

strftime() - Format a Linux Timestamp using a format string

chdir() - Change the current directory

file_exists() - Check if a file exists

filesize() - Return the size of a file, or the number of unread bytes in a stream or socket

print_r() - Dump the contents of an array to the current output

uphp/functions/findnext.txt · Last modified: 2021/09/13 05:57 (external edit)