Edward144 Edward144 - 1 year ago 65
PHP Question

PHP - For loop store all array values as one long string

I need to store each value in an array as one single string. Is it possible to do this?

I have tried using a for loop to achieve this:

for($count = 0; $count < $totalArray; $count++) {
$x = $array[$count];

I'm not sure why I thought this would work. it will obviously, keep changing the value and end up as the last value in the array. But can anyone tell me if there is a way to do this?

Answer Source

You need to add to the previous total, not set it:

$x .= $array[$count];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download