【发布时间】:2020-05-24 19:29:10
【问题描述】:
<?php
$files2 = scandir("signatureforms/");
foreach($files2 as $num => $file) {
if($num < 2) { continue ;}
?>
<button class="signatureformbutton" value="signatureforms/<?php echo $file;?>">
<?php echo $file; ?> <-------'name'
</button>
<?php }
?>
所以我在“signatureforms”文件夹中的每个文件中都制作了一个按钮,但扩展名都在那里。得把那些拿下来。即使在这段代码中,我还会在哪里添加一些东西?在按钮的-name-部分(“”),对吧?
-编辑- 新代码感谢评论者:
<?php
$files2 = scandir("signatureforms/");
foreach($files2 as $num => $file) {
$ext = pathinfo($file, PATHINFO_EXTENSION);
if($num < 2) { continue ;}
?>
<button class="signatureformbutton" value="signatureforms/<?php echo $file;?>"><?php echo str_replace ( $ext , "", $file ); ?></button>
<?php
}?>
努力摆脱那个'。'
-编辑 2-
只需使用 $filename = pathinfo($file, PATHINFO_FILENAME);然后回显 $filename。叹息。
【问题讨论】:
标签: php button bootstrap-4 echo