title: Calculating IP Address Long Form Number for IPv6 Compared to IPv4 Using PHP
body: <p>Currently I have two ways of calculating IPv4 long-form integers:</p>
  
  <pre><code>//IPv4 format: w.x.y.z
  $ip_number = (16777216 * $w) + (65536 * $x) + (256 * $y) + $z;
  $ip_number = ip2long($ip);
  </code></pre>
  
  <p>But how do I calculate IPv6 into a long-form integer?</p>
  
  <p>I'm looking for a function or something that doesn't require me to install any extensions to PHP.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I need the long form integer so I can compare it for an IP range query. Here's an example row for a IPv6 range query:</p>
  
  <pre><code>"58569075684585412230123897272863293440","58569076873007849944088961176022548479","MU","Mauritius"
  </code></pre>