Page 1 of 1

testing variable types

Posted: Fri Oct 24, 2008 3:07 pm
by chiltonk
I am trying to do some light batch processing.

Code: Select all

 
<?php 
$searchParam = $_POST["searchParam"];
$file=fopen("calwid.txt", "r") or exit("Unable to open file!");
 
while (!feof($file))
{
 $i = 0;
 echo $tmpEvent = fgetcsv($file, 178);
 if (in_array($searchParam, $tmpEvent))
 {
    echo $tmpEvent[$i];
    $i++;
 }
}
 
fclose($file);
?>
 
The browser complains that I'm passing in_array an illegal argument, but when I echo $tmpEvent, it prints out Array. Is it, or is it not an array? Effectively this algorithm is going to search a text file, one line at a time, for matches to the string in $searchParam.

Help!
K

Re: testing variable types

Posted: Fri Oct 24, 2008 3:39 pm
by requinix
fgetcsv() returns false when it hits the end of the file, or if there's a problem. false is not an array.