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 Link to comment https://forums.phpfreaks.com/topic/100652-preg_match/ Share on other sites More sharing options...
Schlo_50 Posted April 11, 2008 Author Share Posted April 11, 2008 Anybody? Link to comment https://forums.phpfreaks.com/topic/100652-preg_match/#findComment-514781 Share on other sites More sharing options...
sasa Posted April 11, 2008 Share Posted April 11, 2008 where you setup variable $file Link to comment https://forums.phpfreaks.com/topic/100652-preg_match/#findComment-514784 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 />"); } } } } Link to comment https://forums.phpfreaks.com/topic/100652-preg_match/#findComment-514791 Share on other sites More sharing options...
effigy Posted April 11, 2008 Share Posted April 11, 2008 Try preg_quote($s). Link to comment https://forums.phpfreaks.com/topic/100652-preg_match/#findComment-514794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.