Last active
August 29, 2015 14:08
-
-
Save kreamweb/8ccc50a6251b73e495ba to your computer and use it in GitHub Desktop.
Parser a web font style
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 | |
$handle = fopen("style.css", "r"); | |
$file = 'config.json'; | |
$arr = array(); | |
if ($handle) { | |
$key = ''; | |
while (($line = fgets($handle)) !== false) { | |
preg_match('/[\w-]+/', $line, $matches ); | |
preg_match('/\"([[:ascii:]]+?)\"/', $line, $matches2 ); | |
if( ! empty( $matches )){ | |
if( $matches[0] != 'content'){ | |
$key = $matches[0]; | |
} | |
} | |
if( ! empty( $matches2 ) && $matches[0] == 'content'){ | |
$arr[$matches2[1]] = $key; | |
} | |
} | |
print_r($arr); | |
file_put_contents($file, json_encode($arr)); | |
} else { | |
// error opening the file. | |
} | |
fclose($handle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment