Php inserts a new character at the specified position of the string, and php string specifies the character _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.