preg_replace # 폴더 인식문제
본문
안녕하세요.
특정 디렉토리에 대괄호가 들어가면
$img_path_dir = "/volume/[0001] 이모티콘";
$files = glob($img_path_dir.'/*.*');
인식이 안되어 폴더 안에 파일 리스트가 보여지지 않아
아래 처럼하면 폴더가 인식되어 파일 리스트가 보여집니다.
$img_path_dir = "/volume/[0001] 이모티콘";
$img_path_dir = preg_replace('~[\[?{]~','[$0]',$img_path_dir); // 대괄호 인식문제 해결
$files = glob($img_path_dir.'/*.*');
그런데 # 들어간 폴더는 어떻게 해야 되는지 모르겠네요
$img_path_dir = "/volume/최종화 #나는";
$img_path_dir = preg_replace('~[\[?{]~','[$0]',$img_path_dir); // # 인식 시키기
$files = glob($img_path_dir.'/*.*');
natsort($files); // 보기 좋게 정렬
foreach ( $files as $file ) // 반복
{
echo "<img src='{$file}'><br>";
}
감사합니다.
답변 2
$img_path_dir = preg_replace('~[\[?{]~','[$0]',$img_path_dir); // # 인식 시키기
요디렉토리경로 문제 있는듯 ~이게뭐죠? 그리고 { ] 이건 ;;;;---;;;