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

30 lines
899 B
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
$file = '../../databases/no_db/post.text'; //定义文件的位置
$content = file_get_contents($file);
//分割输出内容
$lines = explode("\n",$content);
$sequence_id = 1; // 设定id起始数字
echo "文章如下: ";
foreach ($lines as $line) {
if (preg_match('/\{([^}]+)\};\{"([^"]+)\"};/', $line, $matches)) {
$data = $matches[1]; // 提取出数据
$title = $matches[2]; // 提取出标题
echo "<br><br>";
echo "文章顺序ID: " . $sequence_id . "<br>"; // 输出顺序ID
echo "" . $data . "\n";
echo "" . $title . "\n";
echo "<a href='https://ww3.tw/blog/md/post/s/$sequence_id' style='color: black;'> 跳转页面</a>";
//echo '链接 (URL): <a herf="">链接</a>';
$sequence_id++; // 每次循环后顺序ID加1
}
}