loops with array_walk or foreach using array??? of variable pairs
| From: | (Helmut Ott) | Date: | Fri, 27 Apr 2001 08:51:21 +0000 |
| Subject: | loops with array_walk or foreach using array??? of variable pairs | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-50580@lists.php.net to get a copy of this message | ||
I need to run the if-construct below (containing a number of variables in
each "branch") using the 2 variables $table1 and $table2 in each run for
each combination
Is it array_walk or foreach ? (I "guess" that here I need a 2-dim-array, or
so, passing always these 2 variables with each run:
This expression has to be run using the 2 variables $table1 and $table2 in
each possible combination, which is :
$table1="a"; $table2="x";
$table1="a"; $table2="y";
$table1="a"; $table2="z";
$table1="b"; $table2="x";
$table1="b"; $table2="y";
$table1="b"; $table2="z";
How do I assign these valies to a multidim array and pass pairs of $table1
and $table2 to a foreach() or array_walk loop?
Now this is the construct that shall be looped thru:
For($i=0,$i<$numfields,$i++)
{
If($table1=="a" || $table1=="b" )
{
if($table1=="a")
{Do this using 4 variables}
elseif($table1=="b")
{Do that using 6 varuables}
}
elseif($table1=="c")
{
if($table2=="x")
{Do this} using 4 variables
elseif($table2=="y")
{Do that using 4 variables}
elseif($table3=="z")
{Do something else using 6 variables}
}
} //endfor
Thanks for any idea on this.