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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -