Detect browser mobile

Detect browser mobile

When I call an aspx page, I want to check the client browser, and if it is a mobile redirect to another page aspnet mobile ...
I have a code in php, and not as it does in jquery

<?php
error_reporting (E_ERROR);
$es_movil=FALSE;
$usuario = $_SERVER['HTTP_USER_AGENT'];
$usuarios_moviles = "Android, AvantGo, Blackberry, Blazer, Cellphone, Danger, DoCoMo, EPOC, EudoraWeb, Handspring, HTC, Kyocera, LG, MMEF20, MMP, MOT-V, Mot, Motorola, NetFront, Newt, Nokia, Opera Mini, Palm, Palm, PalmOS, PlayStation Portable, ProxiNet, Proxinet, SHARP-TQ-GX10, Samsung, Small, Smartphone, SonyEricsson, SonyEricsson, Symbian, SymbianOS, TS21i-10, UP.Browser, UP.Link, WAP, webOS, Windows CE, hiptop, iPhone, iPod, portalmmm, Elaine/3.0, OPWV";
$navegador_usuario = explode(',',$usuarios_moviles);
foreach($navegador_usuario AS $navegador){
if(ereg(trim($navegador),$usuario)){
    $es_movil=TRUE;
     }
//www.starsoft.com.pe
if($es_movil==TRUE){
}else{
}
?>