title: PHP Compress array of bits into shortest string possible
body: <p>I have an array that contains values of 1 or 0 representing true or false values. e.g.</p>
  
  <pre><code>array(1,0,0,1,0,1,1,1,1);
  </code></pre>
  
  <p>I want to compress/encode this array into the shortest string possible so that it can be stored within a space constrained place such as a cookie. It also need to be able to be decoded again later. How do I go about this?</p>
  
  <p>ps. I am working in PHP</p>