1
I have stored in a table, a statement template:
I declare for due purpose that _________ enrollment _______ appeared in the company on the day ______ to _______ to provide the service of __________
Only I’m willing to trade ______ for the data that comes from the bank. Here are my frustrated attempts:
Query:
$sql = mysqli_query($this->conexao,"SELECT * FROM....");
$pe = mysqli_fetch_object($sql);
Attempt 1:
$texto = $visualizar->Modelo;
$buscar = array("____","____","____","____","____");
$alterar = array($pe->Nome,$pe->Matricula,date("d/m/Y"),date("H:i"),$pe->Servico);
$incluir = str_replace($buscar,$alterar,$texto);
echo $incluir;
Attempt 2:
$texto = $visualizarD[1]->Modelo;
$buscar = array("____","____","____","____","____");
$alterar = array($pe->Nome,$pe->Matricula,date("d/m/Y"),date("H:i"),$pe->Servico);
$incluir = '';
foreach($alterar as $altera)
{
$incluir .= str_replace($buscar,$altera,$texto);
}
echo $incluir;
Attempt 3:
$texto = $visualizarD[1]->Modelo;
$buscar = array("____","____","____","____","____");
$alterar = array($pe->Nome,$pe->Matricula,date("d/m/Y"),date("H:i"),$pe->Servico);
$incluir = '';
for($i = 0; $i <= 3; $i++)
{
$incluir .= str_replace($buscar[$i],$altera[$i],$texto);
}
echo $incluir;
Anyway, they all went wrong. The last 02 repeated the text and in each repeated text, the fields ______ were filled by the names I wanted to change, but each name in a given text.
I would just like to point out that my doubt has nothing to do with my previous post, which I was able to successfully resolve. In that case, I need to do the reverse.
Well, there will always be five data to be overwritten?
– Filipe L. Constante
Hello Filipe. This. The 05 data will come from the database.
– user24136
And that doesn’t solve the problem? https://answall.com/q/360697/5878
– Woss
So as a suggestion, and also for ease of reading, I suggest you replace "_" with or #1, #2, #3... and then just replace the information.
– Filipe L. Constante
Perfect Philip. You’re right, I switched ___ to #1, #2, #3, #4, #5 and it worked. Thank you very much. If you want to put in answer, I will mark as accepted.
– user24136
Hi Anderson, thanks for the link, but Filipe’s information helped me.
– user24136