I have this 3 optional input text which is not required at all but at least one should be filled.
<input type="text" name="text1" class="form-control">
<input type="text" name="text2" class="form-control">
<input type="text" name="text3" class="form-control">
and I put their values in array like this
$p =array{
$this->input->post('text1'),
$this->input->post('text2'),
$this->input->post('text3')
}
If I only filled 2 fields, the result is like this:
Array
(
[0] => John
[1] => Jack
[2] =>
)
I implode them:
$passenger = implode(',', $p);
The result:
John, Jack,
What I want is:
John, Jack
How to eliminate the last ',' using PHP? Thank You