3
Hello,
I have a string that the value is zero ($contador = 0;
), other that the value is three ($vezes = 3;
) and another that is $numeros = "13|123456789\n14|123456780\n"
.
I want PHP to do a function (example echo();
) up to the string $contador
arrive on three, and do this function with the 2 values in the string $numeros
, by default:
$ddd = 13; //Pega o valor 13 da string $numeros
$numero = 123456789; //Pega o valor 123456789 da string $numeros
echo "Meu DDD é $ddd e meu celular é $numero!";
//Resposta (vai repetir a função echo acima 3 vezes graças ao valor da string $vezes):
// Meu DDD é 13 e meu celular é 123456789!
// Meu DDD é 13 e meu celular é 123456789!
// Meu DDD é 13 e meu celular é 123456789!
Same thing with the second string value $numeros
. And when the string value $contador
reach three, the script to.
I couldn’t think of anything that would do that, thank you all at once!
13|123456789\n14|123456780\n
Is that how you have the data? I don’t understand the part where the loop goes into it. It’s always 2 phone numbers?– Papa Charlie
@Papacharlie The data is sent from a POST form, of this format
DD|NUMERO
, I want a function that every row that user add (\n
) script does the function I quoted.– Gustavo Dias
You need to format
13|123456789\n14|123456780\n
in 13(*)123456789; 14(*)123456780, that?– Papa Charlie
Exactly, but with so much that the formatting does not affect the result with the function, for example
echo "Meu DDD é 13.. e meu celular é 123456789"
– Gustavo Dias
As if it were an array
– Gustavo Dias
I just read here in php.net, I don’t understand much, so I thought I’d open a question here at stackoverflow
– Gustavo Dias
I gave an answer based on what I understood of your question, if it is incorrect I edit. See if you solve.
– Papa Charlie