Schlo_50 Posted April 11, 2008 Share Posted April 11, 2008 Im trying to use preg_match to find my user defined keywords within my .DAT file. So far I have: $lines = file("data/candidates.DAT"); foreach ($lines as $line) { $data[$key] = explode("|", $line); if($data[$key][5] == "uploaded"){ list($name, $email, $tel, $cv, $canid, $uploaded) = explode("|", $file[$key]); } else { list($name, $gender, $address, $town, $county, $postcode, $dobd, $dobm, $doby, $tel, $worktel, $mob, $email, $qualifications, $skills, $employment, $work, $availability, $job, $salary, $canid) = explode("|", $file[$key]); $search = $_POST['b']; $skill = (str_word_count($search, 1, 'àáãç')); foreach($skill as $s) { print "$s<br />"; if ( preg_match("/".$s."/", $skills) ){ print_r ("Id - $canid<br />"); } } At the moment even nothing is printed out, which I believe is due to my dodgy preg_match() Could somone educate me please? Thanks Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted April 11, 2008 Author Share Posted April 11, 2008 Anybody? Quote Link to comment Share on other sites More sharing options...
sasa Posted April 11, 2008 Share Posted April 11, 2008 where you setup variable $file Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted April 11, 2008 Author Share Posted April 11, 2008 Well spotted, Revised code but I still can't find any matches! $lines = file("data/candidates.DAT"); foreach ($lines as $line) { $data[$key] = explode("|", $line); if($data[$key][5] == "uploaded"){ list($name, $email, $tel, $cv, $canid, $uploaded) = explode("|", $data[$key]); } else { list($name, $gender, $address, $town, $county, $postcode, $dobd, $dobm, $doby, $tel, $worktel, $mob, $email, $qualifications, $skills, $employment, $work, $availability, $job, $salary, $canid) = explode("|", $data[$key]); $search = $_POST['b']; $skill = (str_word_count($search, 1, 'àáãç')); foreach($skill as $s) { if ( preg_match("/".$s."/", $skills) ){ print_r ("Id - $canid<br />"); } } } } Quote Link to comment Share on other sites More sharing options...
effigy Posted April 11, 2008 Share Posted April 11, 2008 Try preg_quote($s). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.