title: how to find out carrier's name in javascript or php
body: <p>I need to create a unique id for every mobile device that access my webpage. I already got the user's screen resolution, browser, OS and location, but I also want to know the carrier's name to make it more accurate.</p>
  
  <p>So far I have:</p>
  
  <pre><code>&lt;script type="text/javascript" language="Javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" language="Javascript" src="http://api.easyjquery.com/easyjquery.js"&gt;&lt;/script&gt;
  
  
  &lt;?PHP
  
  $browsers = array ();
  $osS = array ();
  $tb_query=mysql_query("SELECT * FROM cst_unique_device_index"); 
  while ($rw_query=mysql_fetch_array($tb_query)){
    extract ($rw_query);
    $variable = strtolower($variable); 
  
    if ($type == 2) $browsers[] = $variable;
  }
  
  $osS = array (
      "android",
      "bada",
      "blackberry",
      "brew",
      "ios",
      "lg",
      "linux",
      "motorola",
      "nintendo",
      "palm",
      "playstation",
      "samsung",
      "series",
      "sony",
      "symbianos",
      "unknown",
      "webos",
      "wince",
      "windows");
  
  
    $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
    foreach($browsers as $browser)
      {
      if (preg_match("#($browser)[/ ]?([0-9.]*)#", $agent, $matchBrowser))
        {
        $user_browser = $matchBrowser[1] ;
        $user_browser_version = $matchBrowser[2] ;
        break ;
        }
      }
  
    foreach($osS as $os)
      {
      if (preg_match("#($os)[/ ]?([a-z0-9.]*)#", $agent, $matchOS))
        {
        $user_os = $matchOS[1];
        $user_os_version = $matchBrowser[2] ;
        }
      }
  
  
  
  
  echo $agent .'&lt;br /&gt;'    ;
  echo '
      &lt;table&gt;
        &lt;tr&gt;
          &lt;th&gt;Screen: &lt;/th&gt;
          &lt;td id="user_screen"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;Browser: &lt;/th&gt;
          &lt;td&gt;' . $user_browser . '&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;OS: &lt;/th&gt;
          &lt;td&gt;' . $user_os . '&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;State: &lt;/th&gt;
          &lt;td id="user_state"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
          &lt;th&gt;Carrier: &lt;/th&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
  
      ';
  ?&gt;
  
  
  &lt;script type="text/javascript" language="Javascript"&gt;
  var screenWith = screen.width      
  var screenHeight = screen.height
  
  document.getElementById('user_screen').innerHTML = screenWith+"x"+screenHeight;
  
  
      // 1. Your Data Here
      function my_callback(json) {
          alert("IP :" + json.IP + " nCOUNTRY: " + json.COUNTRY);
      }
  
      function my_callback2(json) {
          // more information at http://api.easyjquery.com/test/demo-ip.php
          //alert("IP :" + json.IP + " nCOUNTRY: " + json.COUNTRY + " City: " +         json.cityName + " regionName: " + json.regionName);
          document.getElementById('user_state').innerHTML = json.cityName;
      }
  
      // 2. Setup Callback Function
     // EasyjQuery_Get_IP("my_callback"); // fastest version
      EasyjQuery_Get_IP("my_callback2","full"); // full version
  
  
  &lt;/script&gt;
  </code></pre>