PHP inserts a new character at the specified position in the string, and the PHP string specifies the character
Because the project uses the DataTable table to load the background data, the table is queried for the policy state selected by the virtual machine, so it is thought to take out the contents of the policy table to form a '[N option]' String, when traversing the list of virtual machines, to put his policy value into a string like ' value= ' 1 ', and then use the explode () and implode () functions to form a new string to return to the foreground, the selected state is implemented.
1$option= ''; 2 3//Remove all policies 4 $sla _query = $this->db->select (' sla_id, Name ')->get (' SLA '); 5 $sla _res = $sla _query->result_array (); 6 if (!empty ($sla _res)) {7 $option. = 'Not protected '; 8 foreach ($sla _res as $k 1 = + $v 1) {9 $option. = '' . $v 1[' name ']. ';}11 $option. = ''; A -}Else { - $option.= 'Not protected'; the } - - -//Select the default protection policy +$VM _query=$this->db->select (' sla_id ')->where (' vm_id '),$vm_id)->get (' TASK_VM ', 1); - $VM _res=$VM _query-Row_array (); +if(Is_null($VM _res[' sla_id ']))$res[' sla_id '] = 0; A$selected= ' value= '.$VM _res[' sla_id ']. '"'; at$new _str_arr=Explode($selected,$option); - $new _option=implode(" {$selected} selected ",$new _str_arr);
http://www.bkjia.com/PHPjc/1137779.html www.bkjia.com true http://www.bkjia.com/PHPjc/1137779.html techarticle PHP Inserts a new character at the specified position in the string, the PHP string specifies the character because the project uses the DataTable table to load the background data, and the table queries the virtual machine for the selected policy state, so I want to ...