Created
July 28, 2014 18:30
-
-
Save allysonsouza/31ec93df98e93c241dc6 to your computer and use it in GitHub Desktop.
Icon Font Associative Array
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 | |
/** | |
* Return an associative array with name and code of the icon from the icon font given in $path argument | |
* | |
* @version 0.0.1 | |
* | |
* @return array Associative array, in the form [name] => [code] of the icon font | |
*/ | |
function icon_array( $path ) { | |
$file = $path; | |
$json = json_decode( url_get_contents( $file ), true); | |
$icons = $json['icons']; | |
$options = array(); | |
foreach ($icons as $icon ) { | |
$options[ $icon['properties']['name'] ] = "&#" . $icon['properties']['code'] . ";"; | |
} | |
return $options; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment