Convert RGB to Hex Color using PHP

sprintf function

<?php

$r = 128;
$g = 96;
$b = 194;
$hexColor = sprintf('#%02x%02x%02x', $r, $g, $b);

echo $hexColor;

Leave a Comment

Cancel reply

Your email address will not be published.