PHP code example of anthocodeur / multicolors-converter

1. Go to this page and download the library: Download anthocodeur/multicolors-converter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anthocodeur / multicolors-converter example snippets


use ColorConverter\HexConverter;

$hex = '#FF0000';
$rgb = HexConverter::hexToRgb($hex);
print_r($rgb); // ['R' => 255, 'G' => 0, 'B' => 0]

use ColorConverter\RgbConverter;

$r = 255;
$g = 0;
$b = 0;
$hex = RgbConverter::rgbToHex($r, $g, $b);
echo $hex; // #ff0000

use ColorConverter\RalConverter;

$r = 255;
$g = 0;
$b = 0;
$ral = RalConverter::rgbToRalValue($r, $g, $b);
echo $ral; // e.g., RAL1000

use ColorConverter\RalConverter;

$ral = 'RAL1000';
$rgb = RalConverter::ralToRgb($ral);
print_r($rgb); // ['R' => 203, 'G' => 186, 'B' => 136]