我有一个代码正在工作,因为我想从1个问题中分离出来。从文件中删除扩展名
你可以在这里看到结果http://test.whatanswered.com/health/what-can-a-first-aider-do.php在“相关文章”下面显示死链接。
以下是应该显示的HTML。
<p><a href="../health/name-of-the-page.php">Name of the page</a></p>
我想剥离破折号和PHP作为上述“页面名称”,但它也剥去从URL破折号和PHP。
的代码是:
<?php
if ($handle = opendir('health')) {
$fileTab = array();
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$fileTab[$file] = strtr(pathinfo($file, PATHINFO_FILENAME), '-', ' ');
}
}
closedir($handle);
shuffle($fileTab);
foreach(array_slice($fileTab, 0, 10) as $file => $health) {
$thelist .= '<p><a href="../health/'.$file.'">'.$health.'</a></p>';
}
}
?>
<?=$thelist?>
pathinfo($ myFile,PATHINFO_FILENAME)和str_replace()....阅读说明书有帮助 –
对不起,但我不明白你在问什么。你能否以更清楚的方式尝试措辞这个问题? – Charles