title: How can I give a color to imagecolorallocate?
body: <p>I have a PHP variable which contains information about color. For example <code>$text_color = "ff90f3"</code>. Now I want to give this color to <code>imagecolorallocate</code>. The <code>imagecolorallocate</code> works like that:</p>
  
  <p><code>imagecolorallocate($im, 0xFF, 0xFF, 0xFF);</code></p>
  
  <p>So, I am trying to do the following:</p>
  
  <pre><code>$r_bg = bin2hex("0x".substr($text_color,0,2));
  $g_bg = bin2hex("0x".substr($text_color,2,2));
  $b_bg = bin2hex("0x".substr($text_color,4,2));
  $bg_col = imagecolorallocate($image, $r_bg, $g_bg, $b_bg);
  </code></pre>
  
  <p>It does not work. Why? I try it also without bin2hex, it also did not work. Can anybody help me with that?</p>