title: Getting or Setting the length of an hexadecimal String in Php
body: <p>I'm trying to convert three types of ints (8,16 &amp; 32 bits), to fixed lengths hexadecimal Strings, in Php.</p>
  
  <p>As an example, the third int is 32 bits unsigned. 
  Its value is set to 300. Converting it to hexadecimal, gives me 12c.</p>
  
  <p>I want to always get a fixed six characters hexadecimal String from my int, i.e in this example : 00 01 2c ... or 00 00 78 if my int's value is 120.
  (N.B : I know 32 bits would overcome this range)</p>
  
  <p>Is there any way of getting the length of an hexadecimal String in Php ?
  Another strategy would be to define the length of the hexa String, but I did not find anything regarding this.</p>
  
  <p>My goal is just to be able to always send a 6 chars sized hexadecimal String to a connected object.</p>
  
  <p>I used 'dechex()' to convert my values to hexadecimal, but I never know the numbers of characters of the output, and therefore can't add a particular number of zeros to it (for my final hex String to be 6 chars long).</p>
  
  <p>I've read something about setting PHP_INT_MAX, but I also read that it would affect all ints, which I don't want.</p>
  
  <p>Thank you very much for your help.</p>