0
I have the following code in PHP:
Array:
$eqCodigos = $_POST["eqCodigo"];
Treatment Attempt to save to Mysql
$eqCodigo1 = explode("\n", $eqCodigos);
$eqCodigo2 = array_filter($eqCodigo1);
$eqCodigo = trim($eqCodigo2);
Query mysql_query
mysql_query("INSERT INTO eq_Codigos (idEquipamento, cdCodigo, cdOpAlteracao, cdDtAlteracao) VALUES ('$idEquipamento', '$eqCodigo[0]', '$eqOpAlteracao', NOW()), ('$idEquipamento', '$eqCodigo[1]', '$eqOpAlteracao', NOW())")
Export from table after insert
INSERT INTO `eq_Codigos` (`idCodigo`, `idEquipamento`, `cdCodigo`, `cdOpAlteracao`, `cdDtAlteracao`) VALUES (27, 164, '123\r', 'Jonatas Messias', '2016-09-23 10:06:16'), (28, 164, '987', 'Jonatas Messias', '2016-09-23 10:06:16');
But at the time saved in the bank the first code of the Array is with " r" at the end, making it difficult at the time I will make the Select.
You can use a regular expression to remove where you have the /r
$ret = preg_split ('/$\R?^/m', $eqCodigos);
– Flavio Misawa
But I can leave the Code the way this or I can use that expression instead of Trim?
– JonatasM
@Flaviomisawa what this Regex was to do?
^
starting at the end?– Guilherme Lautert
\r
or/r
? which one of them– Wallace Maxters
@Wallacemaxters is r, I edited the question and put the table export after Insert for you see how it looks in Mysql.
– JonatasM