title: AS2 code to PHP code
body: <p>I've tried to convert these functions from AS2 to PHP, but I've had no luck.</p>
  
  <p>Here is the original AS2 function:</p>
  
  <pre><code>enc.charsToLongs = function (chars)
  {
      var _loc3 = chars;
      var tlength = Math.ceil(_loc3.length / 4);
      var temp = [];
      var _loc2 = 0;
      for (var _loc1 = 0; _loc1 &lt; tlength; ++_loc1)
      {
          _loc2 = _loc1 * 4;
          temp[_loc1] = (_loc3[_loc2] &lt;&lt; 24) + (_loc3[_loc2 + 1] &lt;&lt; 16) + (_loc3[_loc2 + 2] &lt;&lt; 8) + _loc3[_loc2 + 3];
      } 
      return (temp);
  };
  </code></pre>
  
  <p>This is what I have in PHP:</p>
  
  <pre><code>function charsToLongs($chars)
  {
  
      $_loc3   = $chars;
      $tlength = ceil(count($_loc3) / 4);
      $temp    = array();
      $_loc2   = 0;
      for ($_loc1 = 0; $_loc1 &lt; $tlength; $_loc1++) {
          $_loc2        = $_loc1 * 4;
          $temp[$_loc1] = ($_loc3[$_loc2] &lt;&lt; 24) + ($_loc3[$_loc2 + 1] &lt;&lt; 16) + ($_loc3[$_loc2 + 2] &lt;&lt; 8) + $_loc3[$_loc2 + 3];
      }
      return ($temp);
  }
  </code></pre>
  
  <p>Whenever I run the functions I get different answers for both. I know the AS2 one is working perfectly fine because I've used it many times to encrypt/decrypt strings perfectly fine. There are more functions too but this seems to be the only one I'm stuck on. Could someone tell me what's wrong?</p>
  
  <p>Also: chars ($chars/chars) is an array of character ASCII values of the string I want to encrypt.</p>
  
  <p>Thanks.</p>