RGB to HTML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cjlopesmartins@gmail.com

    RGB to HTML

    Hi

    Please help

    I have this mysql table field with a RGB value like 120-10-200 and I
    nead this php function to convert this value into html color
    #??????

    Thanks in advance





  • Rik Wasmus

    #2
    Re: RGB to HTML

    On Thu, 21 Feb 2008 11:24:24 +0100, cjlopesmartins@ gmail.com
    <cjlopesmartins @gmail.comwrote :
    Hi
    >
    Please help
    >
    I have this mysql table field with a RGB value like 120-10-200 and I
    nead this php function to convert this value into html color
    #??????
    If you need in in css, it can perfectly handle rgb(123,123,123 ) values,
    however, it's a simple matter of explode(), dechex() the items, and
    implode() or concatenate.

    --
    Rik Wasmus

    Comment

    • Toby A Inkster

      #3
      Re: RGB to HTML

      cjlopesmartins@ gmail.com wrote:
      I have this mysql table field with a RGB value like 120-10-200 and I
      nead this php function to convert this value into html color #??????
      <?php
      $rgb = '120-10-200';
      list ($r, $g, $b) = explode('-', $rgb);
      $hex = sprintf('#%02x% 02x%02x', $r, $g, $b);
      ?>



      --
      Toby A Inkster BSc (Hons) ARCS
      [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
      [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 22 days, 17:55.]

      Bottled Water

      Comment

      • Michael Fesser

        #4
        Re: RGB to HTML

        ..oO(Toby A Inkster)
        >cjlopesmartins @gmail.com wrote:
        >
        >I have this mysql table field with a RGB value like 120-10-200 and I
        >nead this php function to convert this value into html color #??????
        >
        ><?php
        > $rgb = '120-10-200';
        > list ($r, $g, $b) = explode('-', $rgb);
        > $hex = sprintf('#%02x% 02x%02x', $r, $g, $b);
        >?>
        <?php
        $rgb = '120-10-200';
        $hex = vsprintf('#%02x %02x%02x', explode('-', $rgb));
        ?>

        SCNR
        Micha

        Comment

        • pakalk

          #5
          Re: RGB to HTML

          On 21 Lut, 18:13, Michael Fesser <neti...@gmx.de wrote:
          .oO(Toby A Inkster)
          >
          cjlopesmart...@ gmail.com wrote:
          >
          I have this mysql table field with a RGB value like 120-10-200 and I
          nead this php function to convert this value into html color #??????
          >
          <?php
          $rgb = '120-10-200';
          list ($r, $g, $b) = explode('-', $rgb);
          $hex = sprintf('#%02x% 02x%02x', $r, $g, $b);
          ?>
          >
          <?php
          $rgb = '120-10-200';
          $hex = vsprintf('#%02x %02x%02x', explode('-', $rgb));
          ?>
          >
          <?php $hex = vsprintf('#%02x %02x%02x', explode('-', '120-10-200')); ?>

          :>

          Comment

          Working...