Created
March 21, 2014 04:21
-
-
Save navitronic/9679452 to your computer and use it in GitHub Desktop.
Display all hexadecimal colours within a less or css file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$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); | |
sort($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