I have created a website with two webpages. One webpage has an html form that allows a potential employee to submit their name, phone number, preferred job, college major, and preferred hours (part time or full time). The information is appended and saved into a text file called applications.txt. The other webpage has an html form that allows a company seeking employees to submit their company name, job opening, required college major, and required hours (full time or part time). This information is appended and saved to a text file called jobOpenings.txt.

Here is an example of what one line would look like from each file.
applications.txt:
Mike Adams,5551112772,Programmer,Computer Science,Full Time

jobOpenings.txt:
Google,Programmer,Computer Science,Full Time

The above example would result in a match. I've already succesfully written code to create the forms and append the info to the proper text files, but how do I use PHP to compare the two text files line by line to see if there is a complete match (between all elements EXCEPT the name, phone number, and company name). For each line from the jobOpenings.txt that matches with the line in applications.txt, I want it to print out something stating that it found a match. If there are no matches, I want it to state that there are no matches found. I've spent a great deal of time trying to figure this out, but with no luck. Can anyone help?

Member Avatar for LastMitch

@Anonymous123

For each line from the jobOpenings.txt that matches with the line in applications.txt, I want it to print out something stating that it found a match. If there are no matches, I want it to state that there are no matches found. I've spent a great deal of time trying to figure this out, but with no luck. Can anyone help?

You need to used preg_match to match the strings.

Read this and there are some examples you can used from this

http://php.net/manual/en/function.preg-match.php

Does this need to be in a text file? Do you not have access to a database?

You would avoid a whole range of problems if you were able to put it all in a database...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.