我有一段PHP代码列出目录,然后创建div,其中包含有关其内部目录的信息。但是,当我执行$ newsPieces [i]时,它不包含字符串中文件夹的名称,为什么?
$("#target").submit(function( event ) {
event.preventDefault(); //prevent submit action here
//Condition on checkbox
if($( "input[name='product[6]']:checked" )){
$('#submit-btn').click(); //handle submit if condition true
}
});
修正版:
<?php
$newsPieces = scandir("posts");
for ($i = 2; $i < count($newsPieces) and $i < 10; $i++) {
$titlefile = fopen($newsPieces[i] . "/title.txt", "r");
$textfile = fopen($newsPieces[i] . "/text.txt", "r");
$fullElement = "<div class='newsPiece'><div class='newsImageHolder'><img class='newsImage' src='" . $newsPieces[i] . "/image.jpg'></div><div class='newsContent'><h1 class='newsTitle'>" . fread($titlefile, filesize($newsPieces[i] . "/title.txt")) . "</h1><p class='newsText'>" . $piece[] = fread($textfile, filesize($newsPieces[i] . "/text.txt")) . "</p><a class='newsLink' href='post?post=" . urlencode($newsPieces[i]) . "'>Continue Reading</a></div></div>";
echo $fullElement;
fclose($titlefile);
fclose($textfile);
}
?>