pathinfo($file, PATHINFO_FILENAME), 'time' => filemtime($file), 'contents' => file_get_contents($file) ]); } usort($posts, fn($a, $b) => $a['time'] == $b['time'] ? 0 : ($a['time'] > $b['time'] ? -1 : 1)); return $posts; } function read_post(string $name) { $name = basename($name); $path = "{$_SERVER['DOCUMENT_ROOT']}/postsources/$name.txt"; if (!file_exists($path)) { return null; } return [ 'name' => $name, 'time' => filemtime($path), 'contents' => file_get_contents($path) ]; }