array_push and in_array problems
<p>I am having a bit of difficulty with this. I want to allow a user to check if a username is available through an AJAX request. The AJAX request calls my php and PHP returns true if the username is not available or false if available.</p>

<p>I wanted to merge the username into the array (if found) and then use in_array to locate a match. It isn't working this way however.</p>

<pre><code>    $res = // database returns any username that matches - (not an array)
    $banned = // database returns an assoc array of banned names

    array_push($banned, strtolower($res['user']));

    if(!in_array(strtolower($requested), $banned)){
        echo 'available';
    } else {
        echo 'not available';
    }
</code></pre>

<p>Here is a sample array from the banned variable:</p>

<pre><code>Array
(
    [0] =&gt; bad1
    [1] =&gt; bad2
    [3] =&gt; 
)
</code></pre>

<p>The 3rd key is null because it wasn't found in the $res variable.</p>

<p>Is there a better way to do this? I also need to convert the values in the array to lowercase as well.</p>
