【问题标题】:rtrim function is not working in this codertrim 函数在此代码中不起作用
【发布时间】:2017-01-09 03:10:53
【问题描述】:

当我使用带有空输入字段的其他复选框时,不需要逗号运算符[,]。 rtrim 函数在这里不起作用,

我的代码

 $compydomain=$this->input->post('companydomain');//get values from                       checkboxes
   if(isset($compydomain)){
    $domains=implode(',', $compydomain);  
    if($domains == 'others'){
        $domaintext=  $this->input->post('companydomaintext');
    }else if($domains == TRUE && $this->input->post('companydomaintext')== TRUE){
        $words = explode( ",", $domains );
        array_splice( $words, -1 );
        $res= implode( " , ", $words );
        $domaintext1 = $res." , " .$this->input->post('companydomaintext'); 
        $test=substr("$domaintext1",-1);
        if($test==",")
        {
            $domaintext=rtrim($domaintext1,",") ;
        }
       else {
        $domaintext=$domaintext1;
          }
        // Concate two values
       }else{
       $domaintext=$domains;
        //$domaintext=  $this->input->post('companydomaintext');
    }



}

【问题讨论】:

  • 请正确格式化您的问题。

标签: javascript php jquery mysql codeigniter


【解决方案1】:

您想使用explode 而不是rtrim
将代码更改为:

$domaintext=explode(',',$domaintext1) ;

【讨论】:

    猜你喜欢
    • 2014-06-03
    • 2016-04-06
    • 2018-06-07
    • 2014-02-01
    • 1970-01-01
    • 2018-04-01
    • 2013-01-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多