Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php validate colour

// ****************************************
// * Check colour
// ****************************************
function validateColour($colour) {
    $COLOR_NAMES = ["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquaMarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenRod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","RebeccaPurple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen"];

    if (in_array($colour, $COLOR_NAMES)) {
        return true;
    } else {
        if (preg_match('/^#[a-f0-9]{6}$/i', $color)) { // ? With #
            return true;
        } else if (preg_match('/^[a-f0-9]{6}$/i', $color)) {
            return true;
        } else return false;
    }
}
// ****************************************
Comment

PREVIOUS NEXT
Code Example
Php :: php append n time pattern to string 
Php :: throw 403 laravel 
Php :: how to check the day of any date in php 
Php :: luhn algorithm 
Php :: read xml file in php wordpress 
Php :: login form using php pdo 
Php :: php apply function to array elements 
Php :: get cookie in laravel 
Php :: parse json nested array form url in php 
Php :: session() in lumen 
Php :: do artisan laravel in code 
Php :: if exists in string count php 
Php :: elementor woo product hide add to cart 
Php :: laravel validation string type 
Php :: Multiple image upload with CodeIgniter 
Php :: export mysql data to word in php 
Php :: laravel model set new attribute 
Php :: associative array in php have same value join them 
Php :: php while jump to next loop 
Php :: php convert array to json 
Php :: PHP | Send Attachment With Email 
Php :: load session in codeigniter 
Php :: php xml to json 
Php :: check current user role 
Php :: Displaying Custom Navigation Menus in WordPress Themes 
Php :: laravel copy row 
Php :: php iterate through a loop 
Php :: create auto image path folder in laravel 8 
Php :: install phpmyadmin ubuntu 18.04 
Php :: Predefined Constants php 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =