( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
// Get the contents of the JSON file
$strJsonFileContents = file_get_contents("webfonts.json");
$characters = json_decode($strJsonFileContents,true);
$characters = $characters['items'] ;
$counter = 0;
foreach ($characters as $row) {
$counter++;
$family = $row['family'] ;
if($counter < 2)
{
// Initialize a file URL to the variable
echo $url = "http://fonts.googleapis.com/css?family=$family";
$output_filename = "$family.css";
$returned_content = get_data($url);
$my_file = "$family.css";
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
fwrite($handle, $returned_content);
}
}
?>