Jump to content

Search the Community

Showing results for tags 'hexadecimal'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. <?php include(dirname( __DIR__ ,1) . "/PDO_db_config.php"); function hexToRgb($hex) { $hex = str_replace('#', '', $hex); $length = strlen($hex); $r = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); $g = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); $b = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0)); return $r.",".$g.",".$b; } function getcolorname($mycolor) { $colors = array( "black" =>array(0,0,0), "green" =>array(0,255,0), "blue" =>array(0,0,255), "cyan" =>array(0,255,255), "red" =>array(255,0,0), "yellow" =>array(255,255,0), "magenta" =>array(255,0,255), "grey" =>array(128,128,128), "white" =>array(255,255,255) ); $tmpdist = 765; $tmpname = "none"; foreach($colors as $colorname => $colorset) { $r_dist = (pow($mycolor[0],2) - pow($colorset[0],2)); $g_dist = (pow($mycolor[1],2) - pow($colorset[1],2)); $b_dist = (pow($mycolor[2],2) - pow($colorset[2],2)); $totaldist = sqrt($r_dist + $g_dist + $b_dist); if ($totaldist < $tmpdist) { $tmpname = $colorname; $tmpdist = $totaldist; } } return $tmpname; } $sql = $pdo->prepare("SELECT * FROM colors"); $sql->execute(); foreach ($sql as $data) { $RGB = hexToRgb($data['HEX']); $arry = explode(',', $RGB); $DEC = "<".round(($arry[0]/255),3).",".round(($arry[1]/255),3).",".round(($arry[2]/255),3).">"; $color = getcolorname($arry); $sql2 = $pdo->prepare("UPDATE `colors` SET `category` = :CAT, RGB = :RGB, LSL = :DEC WHERE (`color_ID` = :color_ID)"); $sql2->bindValue(':CAT', $color, PDO::PARAM_STR); $sql2->bindValue(':RGB', $RGB, PDO::PARAM_STR); $sql2->bindValue(':DEC', $DEC, PDO::PARAM_STR); $sql2->bindValue(':color_ID', $data['color_ID'], PDO::PARAM_STR); $sql2->execute(); } echo "done"; I have a table of colors and I am trying to add color categories to each Color, but it is not categorizing correctly, any Help please.
  2. HI, I want to write a code to convert each character of user enetered data to its equivalent four digit hexadecimal value. eg : if user enters "Hi i am good" convert H to its four digit hexadecimal convert i to its four digit hexadecimal convert blank to its four digit hexadecimal and so on. any suggestions would be great. Many thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.