I need to run a check within a for loop (which could be up to 30,000 iterations ($count)). Which would be faster & why?
Code: Select all
for ($x=0;$x<$count;$x++) {
if ($item === "$a") {
} elseif ($item === "$b") {
} elseif ($item === "$c") {
} 17 more time (20 total)
}Code: Select all
for ($x=0;$x<$count;$x++) {
switch($item) {
case '$a'; break;
case '$b'; break;
case '$c'; break;
17 more as above
}
}....wondering if anyone would know offhand if one or the other would be faster, or has done some benchmarking regarding this type of question.
Thanks!