title: how to convert from base64 to hexadecimal in php?
body: <p>I was thinking to use this:</p>
  
  <pre><code>&lt;?php
  $string1 = 'V2h5IEkgY2FuJ3QgZG8gdGhpcyEhISEh';
  echo base64_decode($string1);
  ?&gt;
  </code></pre>
  
  <p>The output for this example should always be 18 characters! But sometimes this output is less than 18.</p>
  
  <p>24 (base64 characters) multiplied by 6 (bits per base64 character) equals to 144 (bits) divided by 8 (bits per ASCII character) equals to 18 ASCII characters.</p>
  
  <p>The problem is that the output is displayed in plain text; and some characters don't even have a "text representation" and that data will be lost. The next test will show that there are 41 different ASCII characters with no visible output.</p>
  
  <pre><code>&lt;?php
  for ($i = 0; $i &lt;= 255; $i++) {
      $string2 = chr($i);
      echo $i . " = " . $string2 . "&lt;br&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>My plan was to decode the base64 string and from the output in ASCII reconvert it to hexadecimal. Now that is not possible because of those 41 characters.</p>
  
  <p>I  also tried <code>base_convert</code> but there is no base64 support for it.</p>