<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?PHP
function readCSV($csvFile){
$file_handle = fopen($csvFile, 'r');
while (!feof($file_handle) ) {
$line_of_text[] = fgetcsv($file_handle, 1024);
}
fclose($file_handle);
return $line_of_text;
}
// Set path to CSV file
$csvFile = 'computer.csv';
$csv = readCSV($csvFile);
function flatten(array $flat_array) {
$return = array();
array_walk_recursive($flat_array, function($a) use (&$return) { $return[] = $a; });
return $return;
}
$flatarray = flatten($csv);
if(isset($_POST['sub']))
{
if(in_array($_POST['s'],$flatarray))
{
echo $_POST['s']." is in CSV file";
}
else
{
echo $_POST['s']." is not in CSV file";
}
}
echo '<pre>';
print_r($flat_array);
echo '</pre>';
?>
<form action="" method="post">
<input type="text" value="" name="s" />
<input type="submit" value="submit" name="sub" />
</form>
</body>
</html>