If value exists in both array and database <p>I'm trying to check if a value exists in an array, if it does, it should echo the information about that value from the database.</p> <p>What I get now is "null" results, but I expect to get at least three results in the list, that exists in both array and database.</p> <p>This is how a var_dump looks of the array, it's not the whole array but it continues to look the same: <code>$friends = array($friends['data']);</code></p> <pre><code>array(1) { [0]=&gt; array(680) { [0]=&gt; array(2) { ["name"]=&gt; string(17) "One friends name" ["id"]=&gt; string(8) "FRIEND_ID" } [1]=&gt; array(2) { ["name"]=&gt; string(13) "Another friends name" ["id"]=&gt; string(9) "FRIEND_ID" } [2]=&gt; array(2) { ["name"]=&gt; string(22) "Another friends name" ["id"]=&gt; string(9) "FRIEND_ID" } </code></pre> <p>The PHP code:</p> <pre><code>&lt;?php $query_top_list_friends = mysql_query(" SELECT * FROM ".$DBprefix."users WHERE center_id='" . $personal['center_id'] . "' ORDER BY workouts DESC LIMIT 10"); $i = 0; $friends = array($friends['data']); while ($top_list_friends = mysql_fetch_array($query_top_list_friends)) { //Below it should only echo if the "fid" in the database and the "id" in the array is equal, then it should echo information based on that id from the database if($friends[$top_list_friends['fid']]) { $i++; echo "&lt;div class='user'&gt;"; echo "&lt;span class='number'&gt;" . $i . "&lt;/span&gt;"; echo "&lt;span class='name'&gt;" . $top_list_friends['name'] . "&lt;/span&gt;"; echo "&lt;span class='workouts'&gt;" . $top_list_friends['workouts'] . "&lt;/span&gt;"; echo "&lt;/div&gt;"; } } </code></pre> <p>Any ideas how I could fix this?</p>