Jump to content

preg_match


Schlo_50

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.