자동으로 파일 인식해서 연결하는 방법이 있을까요?

자동으로 파일 인식해서 연결하는 방법이 있을까요?

QA

자동으로 파일 인식해서 연결하는 방법이 있을까요?

본문

자동으로 폴더내에 파일을 인식해서 계속 연결해주는 방법이 있을까요?

 

예를들어,

 

index.php

<html> 

<body>

<div class="me">

자동으로 div.me 안index_입력한숫자.html 파일을 계속 불러옵니다.

</div>

</body>

</html>

 

index_1.html

<div class="call"> 

안녕

</div>

 

index_2.html

<div class="call"> 

안녕

</div>

 

index_숫자.html 

<div class="call"> 

안녕

</div>

 

불러온 후 index.php.

<html> 

<body>

<div class="me">

<div class="call"> 

안녕

</div>

<div class="call"> 

안녕

</div>

<div class="call"> 

안녕

</div>

</div>

</body>

</html>

 

폴더내의 index_숫자.html이 있다면 계속 불러오는 방법이 있을까요?

이 질문에 댓글 쓰기 :

답변 3

$a = scandir(G5_PATH."/폴더");

foreach ($a as $s) {
    if (!strstr($s, ".index_")) continue;
    echo "<p>$s</p>";
}
 


<div class="me">
<?php
$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;
}
if(!empty($index_file) && is_array($index_file)){
 sort($index_file);
 foreach($index_file as $file){
  include_once($index_path.'/'.$file);
 }
}
?>
</div>
 
답변을 작성하시기 전에 로그인 해주세요.
전체 46
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT