Reputation: 1833
I have a foreach loop in my php script that exports the results I need.
I would like to have these result be combine into one variable rather than printing each result for me. I don't even know the function of what I'm trying to do is called,
but I know its goes something like this:
if($mins) {
$ips .= $item++;
} else {
$has .= $item++;
}
Therefore, I want to print out all the $items with $mins like this:
"$item $item $item $item $item"
I want $ips to equal/hold the entire "$item $item $item $item $item"
not just singular.
Any kind of help I can get on this is greatly appreciated!
Upvotes: 0
Views: 76
Reputation: 1635
Similarly you can do this with
$ips = null;
$has = null;
foreach ( (array) $Arr AS $key => $val){
if ($mins){
$ips .= $key;
}
$has .= $key;
}
$i++;
}
Upvotes: 1
Reputation: 121
(Answer changed completely due to now clearer question)
Add the result to the relevant array:
if($mins) {
$ips[]=$item;
} else {
$has[]=$item;
}
Print the results with explode:
echo ("ips: ".explode(" ",$ips)."\n");
echo ("has: ".explode(" ",$has));
First parameter of explode() function is a string that will be inserted between the elements of the second param array, a space in this case.
Upvotes: 1