Размер файла: 1.33Kb
<?php
error_reporting(0);
function option($dir,$select){
$conf['items_per_page'] = 99;
if(!($dp = opendir('./'.$dir))) die ('Cannot open ./'.$dir);
$file_array = array();
while ($file = readdir ($dp))
{
if($file[0]!='.')
{
$file_array[] = $file;
}
}
$file_count = sizeof($file_array);
natsort($file_array);
if ($file_count > 0)
{
$first_record = $page * $conf['items_per_page'];
$last_record = $first_record + $conf['items_per_page'];
while (list($fileIndexValue, $file_name) = each($file_array))
{
if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record))
{
$real_file_name = explode('.', $file_name);
if($real_file_name[0]==$select){
$selected = ' selected="selected"';
}
else{
$selected = null;
}
echo '<option value="'.$real_file_name[0].'"'.$selected.'>'.$real_file_name[0].'</option>';
}
}
}
closedir($dp);
}
?>