What’s missing with Switch Statement?
Posted: Fri Aug 20, 2010 1:47 am
In below switch statement, it should have to print only "T","E","S" characters as string "testing" contains these words.
But it is printing all characters including "X" and "Z".
I can’t use "break;" because it will break operation after first case. (After matching "T" with word "testing") but I want to continue the operation even after every case to find the next character.
Please advice if anything is missing.
But it is printing all characters including "X" and "Z".
I can’t use "break;" because it will break operation after first case. (After matching "T" with word "testing") but I want to continue the operation even after every case to find the next character.
Please advice if anything is missing.
Code: Select all
switch(true)
{
case stristr('testing','t'):
echo "T"."<br>";
case stristr('testing','x'):
echo "X"."<br>";
case stristr('testing','e'):
echo "E"."<br>";
case stristr('testing','z'):
echo "Z"."<br>";
case stristr('testing','s'):
echo "S"."<br>";
}