tigomark Posted August 15, 2008 Share Posted August 15, 2008 Ok I am trying to first get a list of stuff from an array created from a database. I am able to do that in funcion LeftSelect but what I would like to do is separate out values that are grabbed from another call and stored in $this->right_asset (vars 1,2,3,4) the values then would populate the RightSelect function LeftSelect(){ $assets = loadAllStuff($getConnection); $html = "<select name=\"target\" multiple=\"multiple\">\n"; if(is_array($assets)){ while(list ($key, $val) = each($assets)){ if (in_array($val->id, $this->asset_select_right)) { array_push($this->right_asset,($val->id, $val->stuff)); }else{ $html .= sprintf("<option value=\"%d\">%s</option>\n", $val->id, htmlspecialchars($val->stuff)); } } } $html .= "</select>\n"; return($html); }//assetSelect function RightSelect(){ $html .=sprintf(" <select name=\"selected\" size=\"10\">"); if(is_array($this->right_stuff)){ while(list($key, $val) = each($this->right_stuff)){ $html .= sprintf("<option value=\"%d\">%s</option>\n", $val->id, htmlspecialchars($val->stuff)); } } $html .=sprintf("</select>"); return($html); } I am trying if (in_array($val->id, $this->asset_select_right)) { array_push($this->right_asset,($val->id, $val->stuff)); which is currently not working in the left. If I take out the if I do get the all of the values so that is working. and the RightSelect is all fubar so I am kinda stuck. Link to comment https://forums.phpfreaks.com/topic/119795-splitting-an-array/ Share on other sites More sharing options...
tibberous Posted August 15, 2008 Share Posted August 15, 2008 Don't give up man. Walk around for a few minutes to clear you head, think about what exactly you are trying to do, and I'm sure you'll get it. Link to comment https://forums.phpfreaks.com/topic/119795-splitting-an-array/#findComment-617160 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.