Replace, tag with attributes for document merging

1

Hello, I am creating a document that makes it possible to merge through tags, but I will allow the user to add a separator within the tag, because I am doing this, in the case of a qualification of a client my system would do so

Qualification tags || cli_name ||, || cli_endereco ||, || cli_numero || - || cli_complemento ||, email: || cli_email ||

Merged qualification considering that you have all the data Name of the Face, Street Address of the Face, 999 - Funds, email: [email protected]

Qualification when missing data (eg missing complement, missing email) Name of the Face, Street Address of the Face, 999 -, email:

What do I do in programming?

<?php
$texto = "Qualifaicação completa do cliente<br>||cli_nome||, ||cli_endereco, ||cli_numero|| - ||cli_complemento|| email: ||cli_email||.";
$texto = str_replace('||cli_nome||', $rs['nome'], $texto);
$texto = str_replace('||cli_endereco||', $rs['endereco'], $texto);
$texto = str_replace('||cli_numero||', $rs['numero'], $texto);
$texto = str_replace('||cli_complemento||', $rs['complemento'], $texto);
$texto = str_replace('||cli_email||', $rs['email'], $texto);
?>

What I would like to enable the client to add extra stuff inside the tags and with a coxetes [] ex:

Qualification tags || cli_name ||, || cli_endereco |||| [] cli_numero |||| [] cli_complemento |||| [email:] cli_email ||

Is there any way to do the replace in the tag and if there is the coxete, put before the tag?

Thinking this way would look like this:

Merged qualification considering that you have all the data Name of the Face, Street Address of the Face, 999 - Funds, email: [email protected]

Qualification when missing data (eg missing complement, missing email) Name of Face, Street Address of Face, 999

HOW TO DO THIS BELOW?

<?php
$texto = "Qualifaicação completa do cliente<br>||cli_nome||, ||cli_endereco||||[, ]cli_numero||||[ - ]cli_complemento||||[ email:]cli_email||.";
$texto = preg_replace('regx', $rs['cli_nome'], $texto);
$texto = preg_replace('regx', $rs['cli_endereco'], $texto);
$texto = preg_replace('regx', $rs['cli_numero'], $texto);
$texto = preg_replace('regx', $rs['cli_complemento'], $texto);
$texto = preg_replace('regx', $rs['cli_email'], $texto);
?>

Thank you Marco

    
asked by anonymous 27.12.2017 / 11:52

0 answers