3

I have a application in which user can upload a resume (which will be .doc file).I am uploading that file inside by uploads folder and name of that file is stored in my db.

Now I want to add search module in which admin can enter a keyword in textbox provided and based upon the keyword user detail should be fetch. Keyword should search all the resume and check weather that keyword is present inside any resume. If yes return the user details.

I found this but not able to understand. Please provide me simple logic to do this.

Thanks in advance

Community
  • 1
  • 1

1 Answers1

0

Try this :

<?php
$file = 'somefile.txt';
$searchfor = 'name';

// the following line prevents the browser from parsing this as HTML.
header('Content-Type: text/plain');

// get the file contents, assuming the file to be readable (and exist)
$contents = file_get_contents($file);
// escape special characters in the query
$pattern = preg_quote($searchfor, '/');
// finalise the regular expression, matching the whole line
$pattern = "/^.*$pattern.*\$/m";
// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
   echo "Found matches:\n";
   echo implode("\n", $matches[0]);
}
else{
   echo "No matches found";
}
Rakesh Shetty
  • 4,548
  • 7
  • 40
  • 79
  • there will be several files I want to search the keyword for every files.This code will search in only one file –  Apr 10 '14 at 07:49