Re: Call func with variable num params (Dont confuse with making func variable params)
| From: | Tom Rogers | Date: | Sat, 27 Jul 2002 05:42:55 +0000 |
| Subject: | Re: Call func with variable num params (Dont confuse with making func variable params) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109931@lists.php.net to get a copy of this message | ||
Hi,
Saturday, July 27, 2002, 11:38:44 AM, you wrote:
MD> Ok, here i made a function that can accept an unknown number of params.
MD> In fact, it's a data interface for a mysql database, when i call the
MD> object's constructor it is in possibility to pass any number of table names
MD> from 1 to x. Now i got this other class called a data interfacer which sends
MD> a certain number of tables to the data interface constructor. I tried doing:
MD> $interface = new data_interface($table1, eval("$table2, $table3, $table4"));
MD> $interface = eval("new data_interface($table1, $table2, $table3, $table4)");
MD> and various other tries. The thing is i can't know how many tables can be
MD> transfered from the data interfacer to the data_interface. So i could make a
MD> if..elseif...elseif until i reach something like 10 tables but still, it's
MD> not a good practice, i'm sure there is a way to emulate real parameters when
MD> they are needed and skip them in the call if you don't have them.
MD> Can anybody help me out?
MD> InsaneCoder
Send the table list as an array then use count($array) to find out how
many in the list or just do a while loop on it.
--
regards,
Tom