shahradelahi /
easy-http
| 1 | <?php |
||
| 2 | |||
| 3 | function generateUpToDateMimeArray(string $url): array |
||
| 4 | { |
||
| 5 | $s = array(); |
||
| 6 | foreach (@explode("\n", @file_get_contents($url)) as $x) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 7 | if (isset($x[0]) && $x[0] !== '#' && preg_match_all('#([^\s]+)#', $x, $out) && isset($out[1]) && ($c = count($out[1])) > 1) { |
||
| 8 | for ($i = 1; $i < $c; $i++) { |
||
| 9 | $s[$out[1][$i]] = $out[1][0]; |
||
| 10 | } |
||
| 11 | } |
||
| 12 | } |
||
| 13 | return $s; |
||
| 14 | } |
||
| 15 | |||
| 16 | $data = generateUpToDateMimeArray('https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types'); |
||
| 17 | echo '<pre>' . json_encode($data, JSON_PRETTY_PRINT) . '</pre>'; |