Core Function GetFolders

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> GetFolders ( <path>, <pattern> ) </pre> === Description === Get an array of all folders in a directory. === Parameters === ==== path ==== The path to use. "" means cu...")
 
(Example)
Line 34: Line 34:
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 
$fList = GetFolders("");
 
$fList = GetFolders("");
foreach($fList as $file)
+
foreach($fList as $folder)
 
{
 
{
println($file);
+
println($folder);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 43: Line 43:
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 
$fList = GetFolders("c:\\windows");
 
$fList = GetFolders("c:\\windows");
foreach($fList as $file)
+
foreach($fList as $folder)
 
{
 
{
println($file);
+
println($folder);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 52: Line 52:
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 
$fList = GetFolders("", m/s\w*nik/);
 
$fList = GetFolders("", m/s\w*nik/);
foreach($fList as $file)
+
foreach($fList as $folder)
 
{
 
{
println($file);
+
println($folder);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 61: Line 61:
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 
$fList = GetFolders("", "cat");
 
$fList = GetFolders("", "cat");
foreach($fList as $file)
+
foreach($fList as $folder)
 
{
 
{
println($file);
+
println($folder);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 70: Line 70:
 
<syntaxhighlight lang="sputnik">
 
<syntaxhighlight lang="sputnik">
 
$fList = GetFolders("", m/(cat)|(dog)/);
 
$fList = GetFolders("", m/(cat)|(dog)/);
foreach($fList as $file)
+
foreach($fList as $folder)
 
{
 
{
println($file);
+
println($folder);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 11:44, 7 November 2012

GetFolders ( <path>, <pattern> )

Contents

Description

Get an array of all folders in a directory.

Parameters

path

The path to use.

"" means current directory.

pattern

Optional; The regex search pattern to use OR the regular text based search pattern to use

Return Value

Success: Returns array of folders.

Failure: Returns empty array.

Remarks

None

Example

Get all folders in current folder

$fList = GetFolders("");
foreach($fList as $folder)
{
	println($folder);
}

Get all folders in windows folder

$fList = GetFolders("c:\\windows");
foreach($fList as $folder)
{
	println($folder);
}

Get all folders in current folder that begin with s have none or more alphabetical chars and end with nik

$fList = GetFolders("", m/s\w*nik/);
foreach($fList as $folder)
{
	println($folder);
}

Get all folders in current folder that contain the text cat

$fList = GetFolders("", "cat");
foreach($fList as $folder)
{
	println($folder);
}

Get all folders in current folder that contain the text cat or the text dog

$fList = GetFolders("", m/(cat)|(dog)/);
foreach($fList as $folder)
{
	println($folder);
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox