Fastest way to check for value existance.
Posted
by Itay Moav
on Stack Overflow
See other posts from Stack Overflow
or by Itay Moav
Published on 2010-05-28T11:57:10Z
Indexed on
2010/05/28
12:02 UTC
Read the original article
Hit count: 161
I have a list of values I have to check my input against it for existence.
What is the faster way?
This is really out of curiosity on how the internals work, not any stuff about premature optimization etc...
1.
$x=array('v'=>'','c'=>'','w'=>);
..
..
array_key_exists($input,$x);
2.
$x=array('v','c','w');
..
..
in_array($input,$x);
© Stack Overflow or respective owner