Files
open-ww3-project-ww3-tw/public/blog/read_file.php

33 lines
1014 B
PHP

<?php
$file = './master/index.txt'; //定义文件的位置
if (file_exists($file)) {
$content = file_get_contents($file);
//分割输出内容
$lines = explode("\n",$content);
//逐行解析
foreach ($lines as $line) {
if (preg_match('/\{([^}]+)\};\{"([^"]+)\"}/', $line, $matches)) {
$data = $matches[1]; // 提取出数据
$title = $matches[2]; // 提取出标题
echo "文章如下: ";
// 输出提取到的内容
echo "<br><br>";
echo "" . $data . "\n";
echo "" . $title . "\n";
echo "<a href='https://ww3.tw/blog/md/post/s/$data' style='color: black;'> 跳转页面</a>";
//echo '链接 (URL): <a herf="">链接</a>';
}
}
//输出内容
//echo "文件 '{$file}' 的内容是: <br><br>\n\n";
//echo $content;
} else {
echo "错误: 文件 '$file' 不存在 ";
}
?>