Execute command from array
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Execute command from array

From: Dave Thomas <gentso@hotmail.com>
Date: Thu Aug 11 2005 - 21:44:33 CEST

I have an array, say something like this (to build a form):

$commands = array(
"Start Date" => "build_date('startdate')",
"End Date" => "build_date('enddate')"
);

Only it will have many more entries. I want to cycle through the array,
and print the first part, but then execute the second part so that it
goes to the function build_date (which returns html code to output).

Right now I am doing it something like this:

echo "<tr><td>Start date</td><td>";
echo build_date('startdate');
echo "</td><td>End date</td><td>";
echo build_date('enddate');
echo "</td></tr>";

Because this is going to have many entries in it, it is getting very
repetitive to do it this way! I am stuck on how to execute that function
(and pass the string) with it already being a string itself.

Any ideas?
Received on Mon Oct 24 02:09:23 2005