I have set a from filed with checkboxes.
<input type="checkbox" name="rights[]" value="1" class="a"> A
<input type="checkbox" name="rights[]" value="2" class="b"> B
<input type="checkbox" name="rights[]" value="3" class="c"> C
Now i want if the user selects option A then i want to set the variable and assign it the value 1. If the user selects multiple values i-e A and B i want to set a variable with the value 'BOTH'.
$right = $this->input->post('rights');
if (in_array ('1', $right)){
$rights = '1';
}
if (in_array ('2', $right)){
$rights = '2';
}
if (in_array ('3', $right) ){
$rights = '3';
}
if (array_intersect($right, array('2', '3') ) ){
$rights = 'both';
}
i have tried this by using in_array() and array_intersect() function but when the user selects either B or C the variable value set to Both, instead of setting the value to B or C. Any Help...