Get variable with all content outside a foreach loop
I'm trying to create a variable outside the foreach loop, containing all
the content that it is getting inside the loop.
What am I doing wrong here?
$fields = array();
foreach($submit_fields as $key => $items) {
if($items->value == true) {
$fields = "
<div class='control-group'>
<label>" . $items->label . "</label>
<div class='controls'>
<input type='text' class='form-control input-small' name='" .
$items->name . "'>
</div>";
}
}
print_r($fields);
No comments:
Post a Comment