I have a function which reads a csv file into an array from there I want to
check if a value is in it.
Basically the csv files look like this:
23123233123,name,so**@one.com
23423412213,name2,so***@one.com
211111,name3,so***@one.com
My function looks like this:
function read_csv($filename, $delim=',')
{
$row = 0;
$dump = array();
$f = fopen ($filename,"r");
$size = filesize($filename)+1;
while ($data = fgetcsv($f, $size, $delim)) {
$dump[$row] = $data;
$row++;
}
fclose ($f);
return $dump;
}
$csv_array = read_csv(csvfile.csv);
I would like to now seach the array to see if a value is in there and do
something from there with it.
if (in_array(211111) == "true"){
echo "Your already in the file";
//note don't write to csv file
}
When I try to check to see if the value is in there It never tells me true
so I can run the commands that I want from there. If anyone can tell me
what I'm doing wrong please let me know.