내 파일은 다음과 같습니다. http://www.mediafire.com/?17bggsa47u4ukmx 기본적으로 다른 확장자를 가진 텍스트 파일입니다.javascript/php에서 텍스트 파일을 구문 분석 하시겠습니까?
이것은 html/javascript/php 용 테스트 리더를 작성하는 테스트입니다. 첫 번째 질문을 의미하는 $$ 0을 읽은 다음 그 다음 줄의 내용을 얻고 싶습니다. 항상 다음 질문이됩니다.
내 코드 : PHP에서 : 파일의
$lines = file("hlm08.dat"); //file in to an array
// Make it search the whole file possible using a while loop by replacing the $$0
if (in_array("$$0", $lines)) {
echo "I found first Question Number";
/// Code to find the question right after it
}
부 :
Hotel and Lodging Management
I
$$0
What do some hotel chains develop to establish formal relationships with employees?
A. Applications
B. Regulations
C. Policies
D. Contracts
/D
Contracts. Contracts are agreements between two or more people or organizations
stating that one party is to do something in return for something provided by
the other party. Employment contracts usually specify what an employee is
expected to do in exchange for being compensated by the hotel chain. These
contracts are often considered legal agreements that establish formal
relationships with employees. Hotel chains often develop regulations and
policies that employees are expected to follow, but these do not establish
formal relationships with the employees. Applications are forms that potential
employees fill out to apply for jobs.
$$1
An impact of antitrust legislation on business is that it prevents hospitality
businesses from
A. experiencing growth.
B. being competitive.
C. raising prices.
D. forming monopolies.
나는 그것이 전체 파일을 검색하고 배열에있는 모든 질문을 넣어하는 방법을 모르겠습니다. 질문은 각 $$ 0 (질문 번호) 바로 뒤에옵니다.
는'line' 더 이상 foreach 루프 내부 배열입니다 (동일한 서버에 텍스트 파일을 가정) . – Starx
@Starx 죄송합니다! 죄송합니다. – slash197
이 코드를 시도했지만 작동하지 않습니다. 나는 내 코드에서 제거한 여분의 괄호를 발견했다. 여전히 효과가 없었습니다. –