Problème avec boucle foreach
Bonjour,
Voici le code d'origine que j'ai et qui marche
Code:
1 2 3 4 5 6 7 8 9 10 11
| $_SESSION['surname'] = $form_surname;
$_SESSION['first_name'] = $form_first_name;
$_SESSION['last_name'] = $form_last_name;
$_SESSION['street_nr'] = $form_street_nr;
$_SESSION['street'] = $form_street;
$_SESSION['npa'] = $form_npa;
$_SESSION['address'] = $form_address;
$_SESSION['phone_home'] = $form_phone_home;
$_SESSION['phone_gsm'] = $form_phone_gsm;
$_SESSION['phone_other'] = $form_phone_other;
$_SESSION['email'] = $form_email; |
Et ensuite j'ai voulu l'intégrer dans une boucle for each, mais ça n'a pas l'air de fonctionner. Qqun pourrait m'aider ?
Merci,
Meilleures Salutations,
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| session_start();
$vars_array = array($form_surname,
$form_first_name,
$form_last_name,
$form_street_nr,
$form_street,
$form_npa,
$form_address,
$form_phone_home,
$form_phone_gsm,
$form_phone_other,
$form_email,);
$vars_array_session = array('surname',
'first_name',
'last_name',
'street_nr',
'street',
'npa',
'address',
'phone_home',
'phone_gsm',
'phone_other',
'email');
foreach (($vars_array_session as $var_array_session) && ($vars_array as $var_array)) {
$_SESSION['$var_array_session'] = $var_array;
echo "$var_array";
echo "$var_array_session"; |