Knowing that the most efficient or quickest method is not always obvious... I ask:
with an array of
How do I efficiently/quickly determine if the string "c" is an exact member of an array of strings or not?
Current contender is:
Thoughts on doing better? Obvious penalty now is matching at the end of the array takes "longer".
D.E.R. Management - IT Project Management Consulting
with an array of
Code:
$array=array("a","b","c","d");
Current contender is:
Code:
$found=0;
$array=array("a","b","c","d");
$matchme="c";
foreach ($array as $a) {
if ($a == $matchme) { $found=1; break; }
}
if ($found) {.......}
Thoughts on doing better? Obvious penalty now is matching at the end of the array takes "longer".
D.E.R. Management - IT Project Management Consulting