Visualizzazione dei risultati da 1 a 2 su 2

Discussione: [PHP] switch

  1. #1

    [PHP] switch

    Ho due valori a cui vanno assegnate gli stessi CASE, cioé:

    Codice PHP:
    switch($scheda['aaa']){

    case 
    1$scheda['aaa'] = "asd"; break;
    case 
    2$scheda['aaa'] = "ddd";      break;
    case 
    3$scheda['aaa'] = "ddd";   break;
    }
    switch(
    $scheda['bbb']){

    case 
    1$scheda['bbb'] = "asd"; break;
    case 
    2$scheda['bbb'] = "ddd";      break;
    case 
    3$scheda['bbb'] = "ddd";   break;

    Come potrei unirlie fare un solo ciclo switch?su php.net non dicono niente in proposito.
    Grazie.
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  2. #2
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    codice:
    $scheda['aaa'] = 1;
    $temp=array(1=>"asd","ddd","ddd");
    $scheda['aaa'] = $temp[$scheda['aaa']];
    print_r($scheda['aaa']); // asd
    think simple think ringo

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.