testing variable types

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chiltonk
Forum Newbie
Posts: 1
Joined: Fri Oct 24, 2008 2:55 pm

testing variable types

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: testing variable types

Post by requinix »

fgetcsv() returns false when it hits the end of the file, or if there's a problem. false is not an array.
Post Reply