Replace, tag with attributes for merging documents

Asked

Viewed 41 times

1

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

Qualification tags ||cli_name||, ||cli_address||, ||cli_number|| - |cli_complement||, email: ||cli_email||

Classification merged considering that it has all the data Cara’s name, Rua Cara’s address, 999 - Fundos, email:[email protected]

Qualification when missing data (e.g., missing complement, missing email) Cara’s name, Rua Cara’s address, 999 -, email:

What I do hj 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 things within the tags and with a pads[] ex:

Qualification tags ||cli_name||, ||cli_address||||[, ]cli_number||||[, ]cli_complement||||[email: ]cli_email||

Is there any way to replace the tag and if there is a pad, put before the tag?

Thinking that way would look like this:

Classification merged considering that it has all the data Cara’s name, Rua Cara’s address, 999 - Fundos, email:[email protected]

Qualification when missing data (e.g., missing complement, missing email) Guy’s Name, Street Guy’s Address, 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

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.