title: Convert string representation of hex to hex
body: <p>I would like to convert in php, a string to hex.</p>
  
  <pre><code>$bin = stringToHex("0x2022800");
  </code></pre>
  
  <p>further down the road I want to nice stuff such as:</p>
  
  <pre><code>for ($x = 5; $x &lt;= 10; $x++) {
      if ($bin &amp; (1&lt;&lt;$x)) {
          echo $x . " = 1 ";
      }else{
    echo $x . " = 0 ";
      }
  }
  </code></pre>
  
  <p>Nothing seems to work unfortunately.</p>