자동으로 파일 인식해서 연결하는 방법이 있을까요? 채택완료
토치
9년 전
조회 4,057
자동으로 폴더내에 파일을 인식해서 계속 연결해주는 방법이 있을까요?
예를들어,
index.php
자동으로 div.me 안에 index_입력한숫자.html 파일을 계속 불러옵니다.
index_1.html
안녕
index_2.html
안녕
index_숫자.html
안녕
불러온 후 index.php.
안녕 안녕 안녕
폴더내의 index_숫자.html이 있다면 계속 불러오는 방법이 있을까요?
댓글을 작성하려면 로그인이 필요합니다.
답변 3개
채택된 답변
+20 포인트
9년 전
오타났었네요.
if (!strstr($s, ".index_")) continue;
가 아니라
if (!strstr($s, "index_")) continue;
네요
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
9년 전
</p><p><div class="me"></p><p><?php</p><p>$index_file = array();
$index_path = 'index 파일이 있는 경로';
$tmp = dir($index_path);
while($entry = $tmp->read()){
//html 파일만 include 함
if(preg_match("/(\.html)$/i", $entry)) $index_file[] = $entry;
}</p><p>if(!empty($index_file) && is_array($index_file)){
sort($index_file);
foreach($index_file as $file){
include_once($index_path.'/'.$file);
}
}</p><p>?></p><p></div></p><p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
�
토치
9년 전
사용해보니 아예 홈페이지 연결이 안됩니다 ㅠㅠ
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인