에서 부분으로 문자열을 분리하는 방법 지금은 유무 : $ 파일 2가 반환 될 때는 PHP
이$path2 = $file_list1;
$dir_handle2 = @opendir($path2) or die("Unable to open $path2");
while ($file2 = readdir($dir_handle2)) {
if($file2 == "." || $file2 == ".." || $file2 == "index.php")
continue;
echo ''.$file2.'<br />';
}
closedir($dir_handle2);
echo '<br />';
, 문자열의 마지막 4 개 문자는 항상 숫자를 더한 파일 확장명이 .txt 같은 종료됩니다 이 :
file_name_here1.txt
some_other-file10.txt
그래서 제 질문은, 어떻게 $ 파일 2가 그래서 두 부분으로, $ file_name을에서 문자열을 반환하고 CALL_NUMBER이 같은 $가
echo 'File: '.$file_name.' Call: '.call_number.'<br />';
,536을? : 분리 할 수있다개
반환 값 : 대신의
File: file_name_here Call: 1
File: some_other-file Call: 10
:
echo ''.$file2.'<br />';
결과 :
file_name_here1.txt
some_other-file10.txt
감사합니다 ....
파일 이름에도 숫자가 포함될 수 있습니까? '예'인 경우 원래 파일 이름이 숫자로 끝나면 ("전화 번호"와 구별 할 수 없음) 어떻게해야합니까? –