<?php
function getrgb($color){
$chars = preg_split('//', $color, -1, PREG_SPLIT_NO_EMPTY);
//split karaters
$color = array();
//maak array
$char[0] = $chars[1].$chars[2];
$char[1] = $chars[3].$chars[4];
$char[2] = $chars[5].$chars[6];
$color[0] = hexdec($char[0]);
$color[1] = hexdec($char[1]);
$color[2] = hexdec($char[2]);
//berekend alles
return $color;
}
if(!empty($_GET['color'])){
$rgb = getrgb($_GET['color']);
//roep fuctie op
echo $_GET['color']." geeft een RGB kleur van Red:".$rgb[0].", Green:".$rgb[1]." en Blue:".$rgb[2];
//eco alles
}
else
{
?>
<form action='<?=$_SERVER["PHP_SELF"];?>' method='get'>
Kleur:<input type='text' name='color' value='#'/><input type='submit' value='Get RBG Code'></form>
<?
}
?>