Let's say I have a for! And that the result of the for is "1 2 3 4 5 6", but each number is a line !!
How do I get all these lines and make it a single variable?
Let's say I have a for! And that the result of the for is "1 2 3 4 5 6", but each number is a line !!
How do I get all these lines and make it a single variable?
You can do this through a string, concatenating the values with .=
or the numbers are all together.
<?php
$arr = range(1,6);
$str = '';
foreach($arr as $item){
$str .= ' '.$item;
}
echo $str;