if (preg_match_all('!(.{,100})!',$_POST['texto'],$match)) { foreach ($match[1] as $line) mysql_query(sprintf("INSERT INTO msg SET campo='%s'",mysql_escape_string($line))); }