Is there a way to query db and select data by specifying the number of chars in the field?
Assuming MySQL:
$sql = "SELECT * FROM table_name WHERE LENGTH(col_name) = " . (int)$length;