Created
August 14, 2017 02:37
-
-
Save shrimp2t/95a94b90abe78bc2fd5e359588e7e021 to your computer and use it in GitHub Desktop.
Get font-awesome icons from css file
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 | |
** | |
* Remove items from an array | |
* @param array $array The array to manage | |
* @param void $element An array or a string of the item to remove | |
* @return array The cleaned array with resetted keys | |
*/ | |
function array_delete($array, $element) { | |
return (is_array($element)) ? array_values(array_diff($array, $element)) : array_values(array_diff($array, array($element))); | |
} | |
$icons_file ='assets/font-awesome/css/font-awesome.css'; | |
if ( ! is_readable( $icons_file ) ) { | |
return array(); | |
} | |
$parsed_file = file_get_contents($icons_file); | |
preg_match_all("/fa\-([a-zA-z0-9\-]+[^\:\.\,\s])/", $parsed_file, $matches); | |
$exclude_icons = array("fa-lg", "fa-2x", "fa-3x", "fa-4x", "fa-5x", "fa-ul", "fa-li", "fa-fw", "fa-border", "fa-pulse", "fa-rotate-90", "fa-rotate-180", "fa-rotate-270", "fa-spin", "fa-flip-horizontal", "fa-flip-vertical", "fa-stack", "fa-stack-1x", "fa-stack-2x", "fa-inverse", 'fa-pull-left', 'fa-pull-right'); | |
$icons = array_delete($matches[0], $exclude_icons); | |
return $icons; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment