首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能在不重复的情况下覆盖两种类型的文件

不能在不重复的情况下覆盖两种类型的文件
EN

Stack Overflow用户
提问于 2018-05-30 16:12:28
回答 1查看 33关注 0票数 0

我知道我有两个预见,但是当我将txt分配给var时,它就不起作用了。它应该为找到的每个html文件编写相应的txt文件等等,只需写一次。我怎么能动摇这个?

代码语言:javascript
复制
<?php

echo '<h2>Escolha o Esquema de MetaDados a utilizar</h2>';
echo '<table cellspacing="0" cellpadding="0" border="0" class="table">';
echo '<tr>';
echo '<th>Esquema de MetaDados</th>';
echo '<th>Descrição</th>';
echo '</tr>';


foreach (glob("Templates/Dinamico/*.html") as $filename) {
    foreach (glob("Templates/Dinamico/*.txt") as $txtname) {
        $fileH = basename($filename, ".html");
        $fileT = basename($txtname, ".txt");
        if ($fileH = $fileT) {
            $txt = file_get_contents($txtname);
            if ($filename != "Templates/Dinamico/formD1.html") {
                echo '<tr>';
                echo '<td>';
                echo "<a strong href='" . $filename . "'>" . $fileH . "</a>";
                echo '</td>';
                echo '<td>';
                echo $txt;
                echo '</td>';
                echo '</tr>';
                //just checking the files
                echo "$filename size " . filesize($filename) . "\n";
            }
        }
    }
}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-04 11:42:44

代码语言:javascript
复制
<?php

    echo '<h2>Escolha o Esquema de MetaDados a utilizar</h2>';
    echo '<table cellspacing="0" cellpadding="0" border="0" class="table">';
    echo '<tr>';
    echo '<th>Esquema de MetaDados</th>';
    echo '<th>Descrição</th>';
    echo '</tr>';

          foreach (glob("Templates/Dinamico/*.html") as $filename) {
          foreach(glob("Templates/Dinamico/*.txt") as $txtname){ 
           $fileH= basename($filename,".html");
           $fileT= basename($txtname,".txt");   
          if($fileH==$fileT){ 
          $txt= file_get_contents ( $txtname); 
        if($filename != "Templates/Dinamico/formD1.html"){ 
            echo'<tr>';
            echo'<td>';
            echo "<a name='".$fileH."'strong href='Templates/Dinamico/formD1.php?id=$fileH'>".$fileH."</a>";
            echo'</td>';
            echo'<td>';
            echo $txt;
            echo'</td>';
            echo'</tr>';

}
}
}
}

    ?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50609264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档