0
Well I have the following array:
$teste = array(1,2,3,4);
When I want to write it on the screen I do so?
foreach ($teste as $c) {
echo $c;
}
The result is: 1234
I need to write the result twice and follow the order, like this: 11223344
Does anyone know how to do this using just one foreach
?
Note: The code inside the foreach
and big and I don’t want to repeat it, I want to find some way to do it in foreach
It’s not enough to do
echo $c, $c
? https://repl.it/@acwoss/EvenOutstandingRuby– Woss
Not da, that was a short example, the code is big and I don’t want to have to repeat it, I have to do it in
foreach
– Hugo Borges
Then your example does not reproduce the real problem, leaving your question insufficiently clear. Please edit the question by elaborating a [mcve].
– Woss
I just edited her
– Hugo Borges
can’t have a loop within the
foreach
? guywhile ($contador < 2)
??– rLinhares
Yeah, good idea.
– Hugo Borges
There is also always the possibility for you to refactor your code and put what is reusable into functions.
– Woss
Can you provide the
foreach
and their code inside the Pastebin ? So the staff can get an idea of what you’re talking about– Isac