need not comma operator[,] when I used others check box with empty input fields. rtrim function is not working here,
My code
$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');
}
}
You want to use explode
instead of rtrim
.
Change code to:
$domaintext=explode(',',$domaintext1) ;