I still don't know how to make it define every array number as a variable...
Let's say I have a table named movies, and I have 2 fields in Movies. title and date. I want to be able to put the exact field name as a variable in format, and define the variable in the format as part of the array (where argument 1 is the table, argument 2 is the format to display it, and every argument beyond that is a field name you want to use).... like...
function echoRepeat() {
$argumentnumber = func_num_args();
$argumentarray = func_get_args();
$query = "SELECT * FROM $argumentarray[0]";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$field1 = $row["$argumentarray[2]"];
print $argumentarray[1];
}
}
So by putting:
echoRepeat("movies", "$field1 is the title of the movie<br />", "title");
It would display something like
The Matrix is the title of the movie
FMJ is the title of the movie
and so on for every movie. Except that would only work when it has one field. I could just put:
$field1 = $row["$argumentarray[2]"];
$field2 = $row["$argumentarray[3]"];
$field3 = $row["$argumentarray[4]"];
$field4 = $row["$argumentarray[5]"];
$field5 = $row["$argumentarray[6]"];
and so on 100 times, but that would make messy code and a limit of only however many times I define it. I want to make it check how many arguments there are (first and second are required, while the third and everything past it are fields), and dynamically use it. So if I have
echoRepeat("movies", "the $field1 came out on $field2<br />", "title", "date");
It will ultimately turn it into
$field1 = $row["$argumentarray[2]"];
$field2 = $row["$argumentarray[3]"];
and if I have
echoRepeat("movies", "the $field1 came out on $field2 . $field4 starred in it and $field3 direcred it. <br />", "title", "date", "director", "actor1");
It will ultimately turn it into
$field1 = $row["$argumentarray[2]"];
$field2 = $row["$argumentarray[3]"];
$field3 = $row["$argumentarray[5]"];
$field4 = $row["$argumentarray[6]"];
So it will make a new $field# (# = starts at 1 and increases by 1 (1,2,3) for every argument passed (starting at the third one), and it will do the same with the array definition after it..
Hope this was clear...