Jump to content

compare the exact words or numbers


vivien

Recommended Posts

just a newbie in php

i got the code in this forum and it really works, but not that exact, it can really compare word from array to per line in a file. but what im trying to do is, to compare the exact word/number.

 

if(strstr($line,$key)) 

echo $line;

 

if $key = 123 and line 1 is 1234 and line 2 is 123

it will still output line1

 

 

 

 

$key = "waka";
$fc = file("file.txt");
$f = fopen("file.txt","r");

foreach($fc as $line)
{
     if(strstr($line,$key)
     echo 4line;
}

fclose($f);
?>

Link to comment
https://forums.phpfreaks.com/topic/235898-compare-the-exact-words-or-numbers/
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.