php 函数将16进制颜色代码转换为 RGB 色值
php 函数将16进制颜色代码转换为 RGB 色值
利用php函数将16禁止的颜色代码转换为RGB色值。
/** * function 16进制颜色转换为RGB色值 * author www.phpernote.com */ function hex2rgb($hexColor){ $color=str_replace('#','',$hexColor); if (strlen($color)> 3){ $rgb=array( 'r'=>hexdec(substr($color,0,2)), 'g'=>hexdec(substr($color,2,2)), 'b'=>hexdec(substr($color,4,2)) ); }else{ $color=str_replace('#','',$hexColor); $r=substr($color,0,1). substr($color,0,1); $g=substr($color,1,1). substr($color,1,1); $b=substr($color,2,1). substr($color,2,1); $rgb=array( 'r'=>hexdec($r), 'g'=>hexdec($g), 'b'=>hexdec($b) ); } return $rgb; }
例如:
print_r(hex2rgb('#F03')); //输出:Array ( [r] => 255 [g] => 0 [b] => 51 )
您可能感兴趣的文章
- php如何将html中的br换行符转换为文本输入中的换行符
- php 将字符串中的连续多个空格转换为一个空格
- php将字符串中全角字符转换为半角字符
- js如何将返回的字符串转换为json格式的数据
- php利用session_set_save_handler()函数将session保存到MySQL数据库中
- php将IP地址转换为真实地址的方法
- php用ZipArchive函数实现文件的压缩与解压缩
- PHP实现限制域名从而保护源代码不被拷贝

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
