When I select fe 2 languages: 'en' and 'de' in the respective checkboxes the 2 results are shown on screen
'en' and 'de'
but in the 4 'if' requests it only selects the last 'on_screen_language_for_print_de' and not the first 'on_screen_language_for_print_en'
foreach($_POST['language_for_print'] as $seleccion) {
echo "<p>".$seleccion ."</p>";
if (!empty($seleccion=='en')){
$on_screen_language_for_print_en="yes" ;
} else {
$on_screen_language_for_print_en="" ;
}
if (!empty($seleccion=="es")){
$on_screen_language_for_print_es="yes";
} else {
$on_screen_language_for_print_es="" ;
}
if (!empty($seleccion=="fr")){
$on_screen_language_for_print_fr="yes";
} else {
$on_screen_language_for_print_fr="" ;
}
if (!empty($seleccion=="de")){
$on_screen_language_for_print_de="yes";
} else {
$on_screen_language_for_print_de="" ;
}
}
Thank you very much for having a look. Manfred
This is a solution:
foreach($_POST['language_for_print'] as $seleccion) {
echo "<p>".$seleccion ."</p>";
//create array with country code
$myArray[]=$seleccion;
//print_r($myArray);
if (in_array("en", $myArray, true)) {
$on_screen_language_for_print_en="yes" ;
} else {
$on_screen_language_for_print_en="" ;
}
if (in_array("es", $myArray, true)) {
$on_screen_language_for_print_es="yes";
} else {
$on_screen_language_for_print_es="" ;
}
if (in_array("fr", $myArray, true)) {
$on_screen_language_for_print_fr="yes";
} else {
$on_screen_language_for_print_fr="" ;
}
if (in_array("de", $myArray, true)) {
$on_screen_language_for_print_de="yes";
} else {
$on_screen_language_for_print_de="" ;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.