Execute($query)){ throw new Exception("Couldn't get question '$field' answer
".$connect->ErrorMsg()); //Checked } $row = $result->fetchRow(); $value = $row[$field]; $found = array_keys($args, $value); if(count($found)) { while($e = each($found)) if($e['value'] % 2 != 0) // we check this, as only at odd indexes there are 'cases' return $args[$e['value']+1]; // returns value associated with found 'case' } // return empty string if none of cases matches user's answer return ""; } }