Help me to convert color in php

by YongC
1 replies
  • WEB DESIGN
  • |
I have an problem with convert rgb or hex color to color name, i had try to search some function on google but all is wrong ...

Ex

myfunction (#f716a0) => it'll echo "Pink"

Does anyone know the best function to do this ?
Thanks for help
#color #convert #php
  • Profile picture of the author SteveJohnson
    You'll have to build your own lookup table relating standard hex values to named colors. You can find one here: CSS Color Names

    Then you'll have to have an rgb to hex converter, which you can find here:
    PHP Convert RGB from/to HTML hex color

    Be careful to pass values to your function using quotes to signify a string:
    myfunction('#aabbcc') {}
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[6526014].message }}

Trending Topics