1
Let’s say I have one for! And that the result of the is is " 1 2 3 4 5 6", only each number is a line!!
How to take all these lines and make it become a single variable?
1
Let’s say I have one for! And that the result of the is is " 1 2 3 4 5 6", only each number is a line!!
How to take all these lines and make it become a single variable?
2
You can do this through a string, concatenating the values with .=
or the numbers all come together.
<?php
$arr = range(1,6);
$str = '';
foreach($arr as $item){
$str .= ' '.$item;
}
echo $str;
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Can transform into an array with
var[] = $i
or concatenate as a string using$var .= $i
– rray
Not wanting to ask too much!! Could you show me an example?
– ivan veloso
u want a string? or array?
– rray
What you find most viable.
– ivan veloso
Is that it? I don’t know what’s feasible in your case, generating an array from the same array doesn’t make much sense, just like it’s in the question.
– rray
My case was more curious!! To see how empty!! Because I had no notion!! With your reply I had a better idea and I was able to do what I wanted! Thank you
– ivan veloso
You have other options: http://answall.com/q/88228/91
– rray