title: Serialize an array and compress the string to use it in a url
body: <h2>The problem:</h2>
  
  <ul>
  <li>We need to serilize an array into a short string, the shorter the better.</li>
  <li>The importance is more reflected on the bigger array than the smaller one.</li>
  <li>The string will be used in a get request so it has to be url decoded.</li>
  </ul>
  
  <h2>Current code snippet</h2>
  
  <pre><code>  /* 
      array (size=3)
        0 =&gt; string '/js/dhdbm78hdfb.js' (length=18)
        1 =&gt; string '/js/dfg4dg.js' (length=13)
        2 =&gt; string '/js/fg8hfhrt.js' (length=15)
        2 =&gt; string '/js/yjtdygj.js' (length=14)
        2 =&gt; string '/js/2q5g54rvfd.js' (length=17)
     */
  
    $json = json_encode($data);
    $gz = gzdeflate($json, 9);
    $base64 = base64_encode($gz);
    $paths = urlencode($base64);
  
    // outputs: i1aK0c8qjtFPyUhJyjW3yEhJS9LLKlbSgQmnpZukpCOLpKVbZKRlFJUgi1VmlaRUpmchCxkVmqabmhSVpaWARGMB
  </code></pre>
  
  <p><em>Not very impressive and pretty slow, I think there should be a better way of doing this...</em></p>
  
  <h2>Question</h2>
  
  <p>What would be the best approach to this problem? How can we present the smallest string possible?</p>
  
  <h2>PS</h2>
  
  <p>It's not the biggest issue if it's slow but it's a variable to be considered. The array will be hashed and retrived from cache when possible.</p>