<?php
$root = $_SERVER["DOCUMENT_ROOT"];
$path = "/NCCDC/test/docs";
$allowed = array('jpg','gif','png'); /* file extension that you want to keep */
$iterator = new DirectoryIterator($root.$path);
/* See php documentation on iterator */
foreach ($iterator as $fileinfo) {
if ($fileinfo->isFile()) {
$path = $fileinfo->getPathname();
$filename = $fileinfo->getFilename(); /*filename like 'picture1.jpg' */
$info = pathinfo($filename);
$ext = $info['extension']; /* extension like 'jpg' */
$filename_noext = basename($filename,'.'.$ext);/*filename without extension like 'picture1' */
/* Test to see if extension is allowed */
if (in_array($ext, $allowed)){
echo "<a href='$path'>$filename_noext</a><br/> \n";
}
}
}
?>
//declare an int with a value of 5 and boolean
var five:int = 5;
var bool:Boolean;
if (five > 6)
{
bool = true;
}
else
{
bool = false;
}
//when comparing booleans, always make sure to
//use two '=' signs, otherwise you'll set the
//value of the variable to what you are trying
//to compare. This is called a logical operator.
if (bool == true)
{
trace("This should actually be false. The value is 5, " +
"greater than 6.")
}
else
{
trace("The value of the int is 5.");
}
/**
*
* @Get File extension from file name
*
* @param string $filename the name of the file
*
* @return string
*
**/
function getFileExtension($filename){
return substr($filename, strrpos($filename, '.'));
}