0
Can we use two different variables in one foreach loop?
For eg: foreach ($_SESSION["stuff"], $_SESSION["diff_stuff"]) as $new_stuff {} Is there any way we can achieve this?
1 Réponse
+ 1
If these two variables have same array structures, you can merge them, save it in new variable, then use it in foreach. For example :
$stuff = array_merge( $_SESSION['stuff'], $_SESSION['diff_stuff'] );
foreach ( $stuff as $new_stuff ) {
// do something
}