나는 다음과 같습니다 디렉토리 구조가 있습니다배열로 파일 구조를 읽을 수 있지만 특정 파일
/expandables
- folder
- folder
- folder
- folder
- BannerInfo.txt
- index.html
folder
각자가 똑같은 stucture을 가지고 있습니다. 하나의 파일은 BannerInfo.txt
과 index.html
입니다. 문제가되는 경우 약 250 개 폴더가 있습니다.
이러한 폴더를 반복하고 각 index.html
개의 파일을 배열에 저장하고 싶습니다. index.html
파일 안에는 나중에 표시 할 문자열을 읽으려는 간단한 HTML과 Javascript 만 있습니다.
개별 폴더에서 index.html
파일 만 필터링하는 방법에 어려움을 겪고 있습니다.
이 목적은 임의로 index.html 파일을 선택하고 내용을 텍스트 영역에 넣기 때문입니다. 내가 반환 된 배열에 간단한 array_rand()
을 할 수 있고 문자열을 뱉어 줄 알았는데.
아이디어가 있으십니까?
는 편집 :<?
$expandables = array();
$expandables = scandir("expandables/");
$count = 0;
foreach($expandables as $expandable) {
if ($expandable != "." && $expandable != "..") {
$expandableCode = "expandables/" . $expandable . "/index.html";
// get value of index.html for select list
$expandableValue = file_get_contents($expandableCode);
// echo out options
echo "<option value='$expandableValue'>$expandable</option>";
}
}
?>
을하지만이 정확히 제대로 작동하지 않습니다 :
나는 이런 식으로 뭔가를 내놓았다. 선택 상자에서 선택한 텍스트 영역을 index.html 내용으로 동적으로 채울 수있는 방법이 있습니까?
파일을 열고 파일을 읽고 작업을 수행해야합니다. PHP 문서를보십시오 : http://www.php.net/manual/en/function.file.php – B4NZ41