Last active
October 22, 2019 17:59
-
-
Save felixdorn/d808c486d3b056e21e44f5ecde333c8d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
require '../vendor/autoload.php'; | |
$Directory = new RecursiveDirectoryIterator(__DIR__ . '\svg'); | |
$Iterator = new RecursiveIteratorIterator($Directory); | |
$svgs = new RegexIterator($Iterator, '/^.+\.svg$/i', RecursiveRegexIterator::GET_MATCH); | |
echo '<pre>'; | |
foreach ($svgs as $svg) { | |
[$name, $extension] = explode('.', basename($svg[0])); | |
$content = base64_encode(file_get_contents($svg[0])); | |
$prefix = ' background-image: url("data:image/svg+xml;base64,'; | |
$suffix = '");' . PHP_EOL; | |
echo ".$name {" . PHP_EOL; | |
echo $prefix . $content . $suffix; | |
echo '}' . PHP_EOL; | |
} | |
echo '</pre>'; |
This file contains hidden or 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 | |
require '../vendor/autoload.php'; | |
$Directory = new RecursiveDirectoryIterator(__DIR__ . '\svg'); | |
$Iterator = new RecursiveIteratorIterator($Directory); | |
$svgs = new RegexIterator($Iterator, '/^.+\.svg$/i', RecursiveRegexIterator::GET_MATCH); | |
foreach ($svgs as $svg) { | |
[$name, $extension] = explode('.', basename($svg[0])); | |
echo '<span class="icon ' . $name . '"></span>' . PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment