RGB in Hex umrechnen

RGB in Hex umrechnen

Dieses PHP-Script rechnet RGB-Werte (0-255) in einen Hex-Wert (#RRGGBB) um.

<?php
/*
    This Software returns hex color by given rgb.

    Copyright (C) 2020 Guido Richter / tintenkobold.de

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License [http://www.gnu.org/licenses/] for more details.
*/

function rgb2hex($r,$g,$b)
{
	return '#'.sprintf('%02X%02X%02X',$r,$g,$b);
}

?>

Schreibe einen Kommentar