<?php
$string = file_get_contents("csv.csv");
$array = explode(",", $string);
$q = strtolower($_GET[q]);
foreach ($array as $value) {
$result = explode(":", $value);
if (strpos($q, $result[0]) !== false) {
$output = $result[1];
}
}
echo $output;
?>
Here is the content of the file csv.csv which I am turning into a string.
hello: how are you doing,
hi: what are you,
df:df
If $_GET[q] (and $q) is hello, the $output is how are you doing. However, if it is hi, I do not get the output what are you or if I do df I do not get df.
Any reason why this is occuring? Thank you in advance for your kind help.
$_GET[q]should be$_GET['q'].undefined constant qin$_GET[q].error_reporting(E_ALL); ini_set('display_errors', 1);always when developing code.$_GET[q]a tireless number of times, and it's no different from$_GET['q']. Also, I'm sure it has nothing to do with the problem that occurs...E_ALL(not suppressing notices) you will most certainly see notices that look like Use of undefined constant q - assumed 'q'