Icon

Random Stuff

colorHTML PHP Class

This is a really simple class that returns color codes from color names and vice-versa.

Usage:
This class is intended to be used as a singleton,
so do not use "new"
create a new instance like this:
[codesyntax lang="php"]
<?php
$color = colorHTML::get_instance();
//then:
$color->get_name('ff0000');
//returns 'red'.
//works with leading # or without: you can use:
$color->get_name('#ff0000');

//It also works in the other direction (color name to hex code):
$color->get_code('red');
//returns '#ff0000'

//you can also use:
$color->get_code('red', true);
//returns 'ff0000' (no leading '#')
?>
[/codesyntax]

This file is not copyrighted whatsoever and falls under the EK license,
found at http://www.yelostudio.com/ek_license.txt
meaning you can use it and modify it however you see fit.

download the source here

by

Category: Code, Free stuff

Tagged: , , , ,