php - Get variable with all content outside a foreach loop -
i'm trying create variable outside foreach loop, containing content getting inside loop.
what doing wrong here?
$fields = array(); foreach( $submit_fields $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 );
change $fields
following:
$fields[] = " <div class='control-group'> <label>" . $items->label . "</label> <div class='controls'> <input type='text' class='form-control input-small' name='" . $items->name . "'> </div>"; }
Comments
Post a Comment