If I have a simple code like this:
$a = "hi";
for ($i = 0; $i < 3; $i++)
{
echo $a;
}
so the output will be hihihi , is it possible to convert it into a string such as $b="hihihi" without through the loop anymore?
I’m using it for other function.
I’ll assume that your situation is a little more complicated than the example given…
One option would be to not echo your variables to the buffer. Instead, append them to your own variable:
However, if, for whatever reason the echoing is not happening in code that you have control over, you could use output buffering.