which is faster, array_key_exists or array_search?
<p>suppose I want to store the list of friends I have on memcache.
sometimes i need to search if a user is on my list and sometime i need to fetch all the list of friends.</p>

<p>would you rather</p>

<pre><code>$friends[] = $friend
</code></pre>

<p>or </p>

<pre><code>$friends[$friend] = 1;
</code></pre>

<p>the rationale is to save as much as ram as decently possible without penalizing speed.
I didn't find any case study for php 5.3.8 that can help me on my little dilemma:
under load, which is faster to perform?</p>

<p>array_key_exists or in_array? (ie: is foo a friend of bar?)</p>

<p>Also, sometimes i need to fetch the whole list of friends so i need to iterate the whole list in order to build an array of friends. not sure at all about the second method, since I don't know yet if there will be more array_search|array_key_exists|in_array or fetch of full friends list.</p>

<p>any idea?</p>
