I got this to work, it list all file (type f) in the current directory, 
you can extend it further.

$ls = split("\n", rtrim (`ls`));

print "<select name=\"test\">";
while (list ($key, $value) = each ($ls)) {
  if (is_file ($value)) print "<option value=\"$key\">$value</option>\n";
}
print "</select>";

=S.

On Tue, 26 Feb 2002, Andrew Slezak wrote:

> Basically I am setting ls > array().  I want each item to be an option in
> the array.  I have have scoured for some time now and this is what I have
> come up with, but it is not populating each file as an <option>?  The select
> box is just empty.  I know this is an array because I have tested with
> print_r.  Stuck!
> 
> Can someone tell me what I am doing wrong?
> ------------------------------------------------
> <?
> $shell_scripts=`ls -1 /sm_scripts|grep -v backup|grep -v outmail|grep -v
> c_`;
> $shell_scripts=rtrim($shell_scripts);
> $arr1=split("\n", "$shell_scripts");
> //print_r($arr1);
> 
> 
> echo "<p>";
> echo "<select name=test>";
> function generate_option_list($arr1, $set) {
> reset($arr1);
> while (list($key,$value) = each($arr1) ) {
>     {$var.="<option value='$key'>$value</option>";}
> } return $var;
> }
> 
> echo "</select>";
> ------------------------------------------------
> ?>
> 
> TIA,
> Andy
> 
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to