2011-02-13 4 views
0

threads라는 폴더가 있고 그 폴더 내에 다른 폴더가 있습니다. 해당 폴더를 배열로 읽는 중 문제가 발생하여 선택 상자에 저장하는 데 문제가 있습니다. 여기 내 코드가있다.루트 디렉토리에있는 폴더에서 디렉토리 가져 오기 PHP

<select value="Please Select a Genre" > 
<?php 
$threads = array(); 
if ($handle = opendir('/Threads/')) { 
    while (false != ($file = readdir($handle))) { 
     if ($file != "." && $file != "..") { 

      array_push($threads,"$file"); 
      print_r ($threads); 


     } 
    } 
    sort($threads); 
    print_r ($threads); 
    for ($i = 0; $i < count($threads); $i++) { 

     print "<option value=\"$threads[$i]\">$threads[$i]</option>"; 
    } 


    closedir($handle); 
    ?> 

</select> 
<br /> 
<input type=\"submit\" name=\"submit\" value=\"Submit\" /> 
</form> 
</center> 
</body> 
</html> 
+1

하고 정확한 문제가 무엇인가? – LeleDumbo

답변

1

소스 코드에 오류가 있습니다.

당신이 누락 닫는}

<select value="Please Select a Genre" > 
<?php 
$threads = array(); 
if ($handle = opendir('/Threads/')) { 
    while (false != ($file = readdir($handle))) { 
     if ($file != "." && $file != "..") { 

      array_push($threads,"$file"); 
      print_r ($threads); 


     } 
    } 
} 
    sort($threads); 
    print_r ($threads); 
    for ($i = 0; $i < count($threads); $i++) { 

     print "<option value=\"$threads[$i]\">$threads[$i]</option>"; 
    } 


    closedir($handle); 
    ?> 
    </select> 
<br /> 
<input type=\"submit\" name=\"submit\" value=\"Submit\" /> 
</form> 
</center> 
</body> 
</html> 
관련 문제