Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2014 04:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save navitronic/9679452 to your computer and use it in GitHub Desktop.
Display all hexadecimal colours within a less or css file.
$less = file_get_contents(__DIR__ . '/app.less');
preg_match_all('/#([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/', $less, $matches);
$colors = array_values($matches[0]);
$colors = array_map(function($color){ return strtolower($color); }, $colors);
$colors = array_unique($colors);
foreach ($colors as $color) {
echo '<div style="float:left; width:80px;height:80px;background-color:' . $color . '">' . $color . '</div>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment