Last active
February 3, 2019 08:54
-
-
Save Frolki1-Dev/9d55df197db28294739b31d3413b1fed to your computer and use it in GitHub Desktop.
Get all icon classes of font awesome
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 | |
$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); | |
?> |
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
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