私のファイルは次のとおりです。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
私はこのコードを試しましたが、動作していません。私は余分なカッコが私のコードでも削除されていることがわかりました。それでも動作しませんでした。 –