PHP inserts a new character at the specified position in the string, PHP string specifies the character _php tutorial

Source: Internet
Author: User

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 ...

  • 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.