Php inserts new characters at the specified position of the string, and php strings specify characters. Php inserts a new character at the specified position of the string. The php string specifies a character. because the project uses a DataTable table to load background data, you need to connect the table to query the selected policy status of the VM, so I want php to insert new characters at the specified position of the string, and php to specify characters
Because the project uses a DataTable table to load background data and needs to connect the table to query the selected policy status of the virtual machine, it is expected to retrieve the policy table content first to form'[N options]'String. when traversing the virtual machine list, the policy value is combined into a string like 'value = "1" 'and then reused.Explode ()AndImplode ()Function to form a new string and return it to the foreground.
1 $ option =''; 2 3 // retrieve 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. ='Unprotected'; 8 foreach ($ sla_res as $ k1 => $ v1) {9 $ option. =''. $ V1 ['name'].''; 10} 11 $ option. =''; 12 13} else {14 $ option. ='Unprotected'; 15} 16 17 18 // select the default protection policy 19 $ vm_query = $ this-> db-> select ('sla _ id ') -> where ('vm _ id', $ vm_id)-> get ('task _ vm ', 1); 20 $ vm_res = $ vm_query-> row_array (); 21 if (is_null ($ vm_res ['sla _ id']) $ res ['sla _ id'] = 0; 22 $ selected = 'value = "'. $ vm_res ['sla _ id']. '"'; 23 $ new_str_arr = explode ($ selected, $ option); 24 $ new_option = implode (" {$ selected} selected ", $ new_str_arr );
The http://www.bkjia.com/PHPjc/1137779.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1137779.htmlTechArticlephp inserts a new character at the specified position of the string, the php string specifies the character because the project uses the DataTable table to load the background data, the table to query the virtual machine selected policy status, so want...