I have been plauged for a few days by this, can anyone see a problem with this function?? function printByType($string, $mode) { (string) $string; $lengths = array( 'VARCHAR' => 10 , 'TINYINT' => 1 , 'TEXT' => 10 , 'DATE' => 7 , 'SMALLINT' => 1 , 'MEDIUMINT' => 2 , 'INT' => 2 , 'BIGINT' => 3 , 'FLOAT' => 4 , 'DOUBLE' => 4 , 'DECIMAL' => 4 , 'DATETIME' => 10 , 'TIMESTAMP' => 10 , 'TIME' => 7 , 'YEAR' => 4 , 'CHAR' => 7 , 'TINYBLOB' => 10 , 'TINYTEXT' => 10 , 'BLOB' => 10 , 'MEDIUMBLOB' => 10 , 'MEDIUMTEXT' => 10 , 'LONGBLOB' => 10 , 'LONGTEXT' => 10 , 'ENUM' => 5 , 'SET' => 5 , 'BIT' => 2 , 'BOOL' => 1 , 'BINARY' => 10 , 'VARBINARY' => 10); $types = array( 'VARCHAR' => 'text' , 'TINYINT' => 'text' , 'TEXT' => 'textarea' , 'DATE' => 'text' , 'SMALLINT' => 'text' , 'MEDIUMINT' => 'text' , 'INT' => 'text' , 'BIGINT' => 'text' , 'FLOAT' => 'text' , 'DOUBLE' => 'text' , 'DECIMAL' => 'text' , 'DATETIME' => 'text' , 'TIMESTAMP' => 'text' , 'TIME' => 'text' , 'YEAR' => 'text' , 'CHAR' => 'text' , 'TINYBLOB' => 'textarea' , 'TINYTEXT' => 'textarea' , 'BLOB' => 'textarea' , 'MEDIUMBLOB' => 'textarea' , 'MEDIUMTEXT' => 'textarea' , 'LONGBLOB' => 'textarea' , 'LONGTEXT' => 'textarea' , 'ENUM' => 'text' , 'SET' => 'text' , 'BIT' => 'text' , 'BOOL' => 'text' , 'BINARY' => 'text' , 'VARBINARY' => 'text'); switch ($mode) { case 'INPUT_LENGTH': foreach ($lengths as $key => $val) { (string) $key; (int) $val; // DETERMINE LENGTH VALUE eg. int(6) GETS 6 preg_match('#\((.*?)\)#', $string, $match); (int) $length_value = $match[1]; // SEARCH $regex = "/" . strtolower($key) . "/i"; $found = preg_match($regex, $string); if ($found !== false) { // DETERMINE ADD INTEGER eg. If the length_value is long enough, determine number to increase html input length switch ($length_value) { case ($length_value <= 7): return $length_value; break; case ($length_value > 7 && $length_value < 15): return $val += ($length_value/2); break; case ($length_value > 14 && $length_value < 101): $result = ($length_value / 5); $divide = ceil($result); return $val += $divide; break; case ($length_value > 100): return 40; break; default: return 7; break; } return $val; } else { return 7; // default value } } break; case 'INPUT_TYPE': foreach ($types as $key => $val) { (string) $val; (string) $key; // SEARCH $regex = "/" . strtolower($key) . "/i"; $found = preg_match($regex, $string); if ($found === false) { return 'text'; // default value } else { return $val; } } break; } } // END function printByType()