필요 파일) data.txt
hello world
good morning
실행소스)
_DIR = 'public_html/data';
$f = file(_DIR.'/data.txt');
결과 화면)
var_dump( $f ); # array(2) {
# [0]=> # string(12) "hello world # "
# [1]=> # string(13) "good morning # " # }
응용) 배열을 다시 라인으로 변경
if ($f != null){
for($i = 0;$i < count($f);$i++){
$arrData['list'] .= $f[$i];
}
}
'개발 > php' 카테고리의 다른 글
php key value array push (0) | 2021.04.01 |
---|---|
php curl header 사용 예시 비즈엠 내 잔액 확인 api (0) | 2021.03.29 |
php list 배열을 변수로 변환 예제 (0) | 2021.02.22 |
php 파일 복사 copy 예제 example (0) | 2021.02.22 |
cron php 리눅스 명령어 정리 (0) | 2021.02.15 |
댓글