Sounds similar to what I just figured out how to do... with the help of some previous user (Kally) here.
| Kód: |
$opts['fdd']['image'] = array(
'name' => 'Photo',
'select' => 'D',
'maxlen' => 125,
'sort' => true
);
$opts['fdd']['image']['values']= array('-- Select an Image --');
$maindir = '../pets/images/' ;
$mydir = opendir($maindir) ;
$exclude = array( "index.php" , "secret.php") ;
while($fn = readdir($mydir))
{ if ($fn == $exclude[0] || $fn == $exclude[1]) continue;
if ($fn != '.' && $fn != '..')
{
if(!ereg("^tn", $fn))
{
$narray[$i]=$fn;
$i++;
}
}
}
sort($narray);
for($i=0; $i<sizeof($narray); $i++)
{
array_push($opts['fdd']['image']['values'],$narray[$i]);
}
closedir($mydir);
|
|
| v13 Napísal: |
Sounds similar to what I just figured out how to do... with the help of some previous user (Kally) here.
| Kód: |
$opts['fdd']['image'] = array(
'name' => 'Photo',
'select' => 'D',
'maxlen' => 125,
'sort' => true
);
$opts['fdd']['image']['values']= array('-- Select an Image --');
$maindir = '../pets/images/' ;
$mydir = opendir($maindir) ;
$exclude = array( "index.php" , "secret.php") ;
while($fn = readdir($mydir))
{ if ($fn == $exclude[0] || $fn == $exclude[1]) continue;
if ($fn != '.' && $fn != '..')
{
if(!ereg("^tn", $fn))
{
$narray[$i]=$fn;
$i++;
}
}
}
sort($narray);
for($i=0; $i<sizeof($narray); $i++)
{
array_push($opts['fdd']['image']['values'],$narray[$i]);
}
closedir($mydir);
|
|
Thanks! That eliminated the need for a table to hold the image names. Now I can just drop an image into the directory and all is well. I did have to make one slight mod. I added:
right before the while. The first time I tried it I got
Undefined variable: i
. Perhaps you had initialized $i further back in your code. Other than that it's working.
|