<?php $colors = [ '#008053', '#008558', '#009264', '#00A76D', '#00A97A', '#00AD7D', '#00B387', '#7FCBAE', ]; foreach($colors as $color) { $rgb = str_split(substr($color, 1), 2); $hex = hexdec($rgb[0]) * 0.2126 + hexdec($rgb[1]) * 0.7152 + hexdec($rgb[2]) * 0.0722; $greyscale = '#'.str_repeat(dechex($hex), 3); $hex = $hex / 255; var_dump($color.' => '.$greyscale.' => '.$hex); }