title: Convert Javascript code to php
body: <p>Can anyone help me convert this javascript function to php?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var t='[{"id_page":14,"in_visible":1,"in_insert":1,"in_update":1}]';
  function hash (s) {
    return s.split("").reduce(
        function(a, b) {
          return a = (a &lt;&lt; 5) - a + b.charCodeAt(0),  a &amp; a  
        }, 0
    ).toString()
  }
              
  alert(hash(t));</code></pre>
  </div>
  </div>
  </p>
  
  <p>I'm trying this php script:</p>
  
  <pre><code>function fun($a, $b)
  {
      return $a = ($a &lt;&lt; 5) - $a + ord(substr($b,0,1));//  $a &amp; $a;
  }
  
  $v = '[{"id_page":14,"in_visible":1,"in_insert":1,"in_update":1}]';
  $a = str_split($v);
  $r = array_reduce($a,'fun',0);
  print_r($r);
  </code></pre>