User Tools

Site Tools


uphp:functions:findfirst

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

uphp:functions:findfirst [2017/03/05 12:21]
jeff
uphp:functions:findfirst [2021/09/13 05:57]
Line 1: Line 1:
-======findfirst====== 
-<badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge> 
- 
-Start searching the current folder for files matching a pattern and attributes 
- 
-====Description==== 
-<well size="sm"><html><span style="font-size:125%;color:green;">array 
-<span style="color:black;"></html>[[findfirst]] 
-<html>( 
-<span style="color:green;">string 
-<span style="color:blue;">$pattern<span style="color:black;">, 
-<span style="color:green;">int 
-<span style="color:blue;">$attributes 
-<span style="color:black;">) 
-</html></well> 
- 
-Begin a search to iterate through a list of files 
- 
-====Parameters==== 
-<html><span style="color:blue;"><b>pattern</b><span style="color:black;"></html>:  Partial or full pattern such as *.* or *.cgi 
- 
-<html><span style="color:blue;"><b>attributes</b><span style="color:black;"></html>:  Matching mask, leave at 255 to include all. See [[os:FAT file attributes]] for more information. 
- 
-====Return Value==== 
-Array of the first matching file containing the following keys and values: 
- 
-^KEY^TYPE^VALUE^ 
-|filename|<html><span style="color:green;">string</html>|Name of the file| 
-|attributes|<html><span style="color:green;">int</html>|File attributes (FAT)| 
-|filesize|<html><span style="color:green;">int</html>|File size in bytes| 
-|timestamp|<html><span style="color:green;">int</html>|FAT timestamp of last save| 
- 
-====Example==== 
-<code php> 
-<pre><? 
-//list all files in the root directory: 
-chdir("/"); //change to the root folder 
-$arr=findfirst("*.*",255-16); //get the first entry matching any file, excluding directories 
-while ($arr) { 
-  print($arr['filename']."\r\n"); 
-  $arr=findnext(); //get another matching file 
-} 
-?> 
-</pre> 
-</code> 
- 
-====See Also==== 
-[[findnext()]] - Return next matching file information 
- 
-[[chdir()]] - Change uPHP's 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 
- 
-[[timefromfat]] - Convert a FAT filetime to a native Linux timestamp 
- 
-[[uphp:control_structures:while]] - Flow control structure for a conditional loop 
  
uphp/functions/findfirst.txt · Last modified: 2021/09/13 05:57 (external edit)