Search code examples
phpcodeignitercodeigniter-3string-concatenation

Add two input values as string in Codeigniter


I´m trying to add two input values as string not as number, the problem is that they are actually numbers.

'clabe' => $this->input->post('clabe2') + $this->input->post('dc') 

Where clabe2 = 123 and dc = 4;

I want to get result as 1234 not 127

Any help will be appreciated


Solution

  • Do something like this

    Use concatenation operator . for string concatenation

    'clabe' => $this->input->post('clabe2') . $this->input->post('dc');
    

    For more : http://php.net/manual/en/language.operators.string.php