What's the most efficient way to tell if a single character is alphanumeric in PHP?
<p>What's the most efficient way to tell if a single character is alphanumeric in PHP?</p>

<p>I know I could do something like:</p>

<pre><code>function isSingleAlphaNum($chr){
    if(!is_string($chr){
        return false;
    }

    //capture the first alphanumeric character, replace the whole string with it
    $test = preg_replace('#([a-zA-Z0-9]{1}).*#','$1',$chr);
    if($test == $chr){
        return true;
    }

    return false;

}
</code></pre>

<p>This seems clunky. Is there a better way?</p>
