PHP LANGUAGE: USAGE DE SWITCH
Dans la plupart des usages de SWITCH que je vois sur le net, SWITCH est utilis avec ECHO pour afficher. Moi je voulais l’utiliser pour présenter des options de calculs. Voici un exemple ci-dessous.
$de_vol_col=$volrestotj; switch ($de_vol_col){ case ($de_vol_col <= 0.75): $section = 0.35; echo "Diam 8'' x Haut 44po"; break; case ($de_vol_col >0.75 && $de_vol_col <1): $section = 0.44; echo "Diam 9'' x Haut 40''"; break; case ($de_vol_col >=1 && $de_vol_col <=1.10): $section = 0.44; echo "Diam 9'' x Haut 48''"; break; case ($de_vol_col >1.10 && $de_vol_col <= 1.33): $section = 0.55; echo "Diam 10'' x Haut 47''"; break; case ($de_vol_col >1.33 && $de_vol_col <= 1.5): $section = 0.55; echo "Diam 10'' x Haut 54''"; break; case ($de_vol_col >1.50 && $de_vol_col <=1.75): $section = 0.79; echo "Diam 12'' x Haut 48''"; break; case ($de_vol_col >1.75 && $de_vol_col <=2): $section = 0.79; echo "Diam 12'' x Haut 52''"; break; case ($de_vol_col >2 && $de_vol_col <=2.50): $section = 0.92; echo "Diam 13'' x Haut 54''"; break; case ($de_vol_col >2.50 && $de_vol_col <=3): $section = 1.07; echo "Diam 14'' x Haut 65''"; break; case ($de_vol_col >3 && $de_vol_col <=4): $section = 1.40; echo "Diam 16'' x Haut 65''"; break; case ($de_vol_col >4 && $de_vol_col <=5.5): $section = 1.77; echo "Diam 18'' x Haut 65''"; break; case ($de_vol_col >7 && $de_vol_col <=7): $section = 2.41; echo "Diam 21'' x Haut 72''"; break; case ($de_vol_col >7 && $de_vol_col <=10): $section = 3.14; echo "Diam 24'' x Haut 72''"; break; case ($de_vol_col >10 && $de_vol_col <=15): $section = 4.91; echo "Diam 30'' x Haut 72''"; break; case ($de_vol_col >15 && $de_vol_col <=20): $section = 7.07; echo "Diam 36'' x Haut 72''"; break; case ($de_vol_col >20 && $de_vol_col <=30): $section = 9.62; echo "Diam 42'' x Haut 72''"; break; case ($de_vol_col >30 && $de_vol_col <=40): $section = 12.57; echo "Diam 48'' x Haut 72''"; break; case ($de_vol_col >40 && $de_vol_col <=75): $section = 21.65; echo "Diam 63'' x Haut 86''"; break; default: echo "Diam D'' x Haut H''"; break; }