Skip to content

Instantly share code, notes, and snippets.

@allysonsouza
Created July 28, 2014 18:30
Show Gist options
  • Save allysonsouza/31ec93df98e93c241dc6 to your computer and use it in GitHub Desktop.
Save allysonsouza/31ec93df98e93c241dc6 to your computer and use it in GitHub Desktop.
Icon Font Associative Array
<?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