php - Foreach loop; Undefined index: position. Syntax appears correct though -


i'm getting undefined index: position error using code below, yet not see errors in doing. looks example on php page (http://php.net/manual/en/control-structures.foreach.php) :

$position_list = array( 1 => "chair",  2 => "saca", 5 => "school", 0 => "disabled", );  foreach ($position_list $priv_id=>$position) {     $data['position'] .= '<option value="'.$position_list[$priv_id].'"'; //throws error here      if ($position_list[$priv_id] == $privilege_id) {             $data['position'] .= " selected=\"selected\"";          }      $data['position'] .= '>'.$position.'</option>';   //throws error here }    

i commented code errors thrown.

edit: $data['position'] whole different thing, not suppose refer position used in foreach array.

edit2: more code. here @ end of php file:

$page->html .= file::text_replacement( "add_user.inc", $data ); 

in add_user.inc file have line this:

<td><select name="privilege_id">%%position%%</select></td> 

%%position%% replaced $data['position'] variable upon file class being called. not meant $position.

$data['position']probably isn't defined. *probably* mean$data[$position].

define $data['position'] before loop:

$data['position'] = ''; foreach ($position_list $priv_id=>$position) { 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -