I'm trying to pass a string variable to a custom function, echoing its 
*value on one line, and its *name (that is, its key if this were an array 
instead of a string) on another line. I searched the manual's sections on 
variable functions and string functions, to no avail.  I tried key(), but 
it just produces a warning that $var is not an array.  Example:

build_select_menu($display,array("Y","N")); 

function build_select_menu($field,$options_array)
   {
   echo '<p><SELECT NAME="' . key($field) . '">' . "\n";  //need to echo 
name of string passed as first argument

   foreach($options_array as $option)
      {
      echo '<OPTION VALUE="Y"';
         if($field=="$option") {echo ' SELECTED';}
      echo ">$option</OPTION>\n";
      }
   echo  "</SELECT></p>\n";
   }

Thanks!

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to