Hey all i am trying to search through a CSV file using the following code:
$fh = fopen($myFile, "r");
$os = array(fgetcsv($fh));
if (in_array("12.56.102.44", $os)) {
echo "Got it!";
}
The CSV is in this format:
"132.89.14.110","41.98.365.111","12.56.102.44","77.295.10.111",
However, that does not work so i am sure i am using it incorrectly…
Any help would be great!
fgetcsv()already returns an array. You should be calling the function like this:Putting the return value inside an array will make the value of
$osthe following:If there are multiple lines in your file that you need to check, you’ll have to make use of a loop, for example: