title: Nibble Hex from Java to PHP
body: <p>I'm translating one app from java to php and i'm finding some trouble.</p>
  
  <p>I have a string like this <code>98191107990D0000EF050000789C65970BCCD75318C7CFEFFC</code> ... in java there's this function where I pass this string as parameter:</p>
  
  <pre><code>private static byte[] decodeNibbleHex(String input)
    {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      char[] chars = input.toCharArray();
      for (int i = 0; i &lt; chars.length - 1; i += 2) {
        char[] bChars = new char[2];
        bChars[0] = chars[i];
        bChars[1] = chars[(i + 1)];
        int val = Integer.decode("0x" + new String(bChars)).intValue();
        baos.write((byte)val);
      }
      return baos.toByteArray();
    }
  </code></pre>
  
  <p>but... i don't know to to translate this function in PHP... i tried too many times and i'm becoming crazy! i tried with a for cycle, with this <code>eval("\$hex = 0x" . $dati[$i].$dati[$i+1] . ";");</code> and this <code>$binary_string = pack("h*" , $dati[$i].$dati[$i+1]);</code> and many many other functions...</p>
  
  <p>If someone understand Java and can help me I will appreciate it!!</p>
  
  <p>Thank guys!</p>