\s+JSON.*?<\/a>/is', $data, $m); foreach ($m[1] as $url) { $file = str_replace(['/', '.'], '_', $url); // fix file name if (!is_cached($file . '.json')) { echo 'Downloading: ' . 'https://checksums.kubik-rubik.de/' . $url . PHP_EOL; $json = file_get_contents('https://checksums.kubik-rubik.de/' . $url); set_cache($file . '.json', $json); } else { $json = get_cache($file . '.json'); } // decode json, write hash values to one file echo 'Parsing json file: ' . $file . PHP_EOL; foreach (json_decode($json) as $k => $hash) { fputs($fp, $hash . "\n"); } } } } function fetch_jquery($fp) { echo 'Fetching jQuery' . PHP_EOL; $data = file_get_contents('https://code.jquery.com/jquery/'); preg_match_all('/ compressed.dat'); // gzencode $hash = hash_file('sha256', 'compressed.dat'); file_put_contents('compressed.sha256', $hash); echo 'SHA256 is ' . $hash . PHP_EOL;