Hier ist meine Datei: http://www.mediafire.com/?17bggsa47u4ukmx Es ist im Grunde eine Textdatei mit einer anderen Erweiterung.Parsing Textdateien in Javascript/PHP?
Es ist ein Test, dass ich einen Testleser für in html/javascript/php baue. Ich möchte, dass es das $$ 0 liest, was die erste Frage bedeutet, und dann die nächste Zeile des Inhalts danach bekommen, was immer eine Frage sein wird.
Mein Code: in 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
}
Teil des Dossiers:
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.
Ich bin nicht sicher, wie es die gesamte Datei zu machen scannen und alle Fragen in einer Reihe gelegt. Die Fragen kommen direkt nach jedem $$ 0 (Nummer der Frage).
'line' ist nicht mehr ein Array innerhalb der foreach-Schleife, um zu bestimmen . – Starx
@Starx Hoppla! Es tut uns leid. – slash197
Ich habe diesen Code versucht, aber es funktioniert nicht. Ich habe eine zusätzliche Klammer gefunden, die ich auch in meinem Code entfernt habe. Es hat immer noch nicht funktioniert. –