Skip to content

Instantly share code, notes, and snippets.

@nicelife90
Created December 6, 2016 21:50
Show Gist options
  • Save nicelife90/9dcd6ef4c2fb401f525cb6dde8219c65 to your computer and use it in GitHub Desktop.
Save nicelife90/9dcd6ef4c2fb401f525cb6dde8219c65 to your computer and use it in GitHub Desktop.
Font Awsome to PHP Array
<?php
$pattern = '/\.(fa-(?:\w+(?:-)?)+):before\s+{\s*content:\s*"\\\\(.+)";\s+}/';
$subject = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/css/font-awesome/css/font-awesome.css');
preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER);
echo '$fa_icon = [';
foreach($matches as $match) {
echo "'$match[1]' => '<li class=\"fa $match[1]\"></li>',\n";
}
echo ']';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment