Created
August 4, 2020 17:00
-
-
Save pweinzettel/0a2931e32a497f153701dd7d0d87ab1e to your computer and use it in GitHub Desktop.
List all free fontawesome 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
<?php | |
function proc_fa($page) { | |
$curl = curl_init($page); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
$tmp = curl_exec($curl); | |
curl_close($curl); | |
preg_match('/window.__inline_data__ =(.*?)<\/script>/s', $tmp, $match); | |
$res = json_decode($match[1]); | |
$prepend = ",'"; | |
$append = "'"; | |
foreach ($res[1] as $rex) { | |
foreach ($rex as $key => $value) { | |
if (!isset($value->attributes)) { continue; } | |
foreach ($value->attributes->membership->free as $member) { | |
$ico = (isset($prepend)?$prepend:''); | |
switch ($member) { | |
case 'brands': | |
$ico .= "fab fa-"; | |
break; | |
case 'solid': | |
$ico .= "fas fa-"; | |
break; | |
case 'regular': | |
$ico .= "far fa-"; | |
break; | |
default: | |
echo ">> ERR-001: ".$member.PHP_EOL; | |
die(); | |
} | |
$ico .= $value->attributes->id."'".PHP_EOL; | |
echo $ico; | |
} | |
} | |
} | |
} | |
$url = 'https://fontawesome.com/cheatsheet/free/'; | |
proc_fa($url); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment