Skip to content

Instantly share code, notes, and snippets.

@Frolki1-Dev
Last active February 3, 2019 08:54
Show Gist options
  • Save Frolki1-Dev/9d55df197db28294739b31d3413b1fed to your computer and use it in GitHub Desktop.
Save Frolki1-Dev/9d55df197db28294739b31d3413b1fed to your computer and use it in GitHub Desktop.
Get all icon classes of font awesome
<?php
$json = json_decode(file_get_contents('icons.json'));
$icons = [];
foreach ($json as $class => $icon) {
$name = 'fa-' . $class;
foreach ($icon->styles as $type) {
switch($type) {
case 'solid':
$c = 'fas ' . $name;
$icons[$c] = $icon->unicode;
break;
case 'regular':
$c = 'far ' . $name;
$icons[$c] = $icon->unicode;
break;
case 'brands':
$c = 'fab ' . $name;
$icons[$c] = $icon->unicode;
break;
}
}
}
echo "<pre>";
print_r($icons);
echo "</pre><br>";
echo count($icons);
?>
The icons.json you can get under https://fontawesome.com/how-to-use/on-the-web/setup/hosting-font-awesome-yourself.
Open the ZIP archive and navigate to metadata > icons.json.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment