$letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
$x = (1==1 || 2==2);
$y = (3==3 || 4==4);
$z = (5==5);
foreach ($letters as $key => $letter) {
switch ($letter) {
case 'a':
echo "a";
break;
case 'b':
echo "b";
break;
case 'c':
echo "c";
break;
case 'd':
echo "d";
break;
case 'e':
echo "e";
break;
case 'f':
echo "f";
break;
case 'g' && ($z || $y):
echo "g";
break;
case 'h' && ($x):
echo "h";
break;
}
}
I don't know why but at the last two cases the 'g' and 'h' It doesn't work properly and gets a double 'g', The result i expect is
abcdefgh but i keep getting abcdefgg, What am I doing wrong?