PHP水平有待提高- <?php
- $in = fopen('a.txt', 'rb');
- $out = fopen('x.txt', 'wb');
- if (!$in || !$out) die();
- while (!feof($in)) {
- $str = trim(fgets($in));
- $str = iconv('gbk', 'utf-8', $str);
- $arr = explode('@@', $str);
- $str = sprintf('<a href="/x/%s/%s">%s</a>',
- urlencode($arr[0]), urlencode($arr[1]), $arr[1]);
- $str = iconv('utf-8', 'gbk', $str);
- fputs($out, "$str\r\n");
- }
- fclose($in);
- fclose($out);
- ?>
复制代码
|