텍스트 파일의 특정 줄을 읽으려고합니다.특정 줄의 파일 읽기 php
내 텍스트 파일은 같다 :
accueil: demo1,demo2
services: demo3,demo4
essai: [email protected]
내가 주석이 라인을 찾을 수 있습니다 :
#
# Aliases in this file will NOT be expanded in the header from
# Mail, but WILL be visible over networks or from /bin/mail.
# Basic system aliases -- these MUST be present.
mailer-daemon: postmaster
postmaster: root
# General redirections for pseudo accounts.
bin: root
nscd: root
pcap: root
apache: root
webalizer: root
# boite fonctionnelles
# GEMEL
accueil: demo1,demo2
services: demo3,demo4
essai: [email protected]
난 후에 재 작업이 줄을 수집 할 #의 GEMEL을
다음과 같이 할 수 있습니다.
if($lines = file($filename)){
foreach ($lines as $key => $value) {
if(preg_match("/# GEMEL/", $value))
for ($i=0; $i < ; $i++) {
# code...
}
}
}
하지만 이중 탭이 정말 좋지는 않습니다 ... 해결책은 # GEMEL을 찾은 후 포인터를 이동하는 것이지만 어떻게 할 수 있습니까?
들으 @shadyyx, 난이 두 개의 루프 다른 솔루션에 비해 가장 좋은 방법 같아요. 이전에 나는 ** fseek **도 시도했지만 두 개의 루프도 있습니다 : 하나는 치료를위한 것이고 다른 하나는 치료를위한 것입니다. 어쨌든, thx;) – mpgn
당신은 오신 것을 환영합니다! – shadyyx