选中复选框时如何组合两个数组[关闭]

I have two array and two check boxes. The array values are

  $a={1,2,3,4,5} --->It' for first Check box
  $b={5,6,7,8,9} --->It' for Second Check box

When I check the first check box only I want the result is

 $c[0]=1,$c[1]=2,$c[2]=3,$c[3]=4,$c[4]=5

And I check the second check box only I want the result is

$c[0]=5,$c[1]=6,$c[2]=7,$c[3]=8,$c[4]=9

And I have check both check boxes I want the result is

$c[0]={1+5},$c[1]={2+6},$c[2]={3+7},$c[3]={4+8},$c[4]={5+9}

It's Possible?

You can achieve this using a for() loop. Please note that this code assumes both arrays are the same size:

$c = array();
for($i = 0; $i < count($a); $i++)
{ 
    $c[] = ($a[$i] + $b[$i]);
}

print_r($c);

Yes you can do it following way

<?php
 $a = array(1,2,3,4,5);
 $b = array(5,6,7,8,9);
 $c = array();  //for result
   if(isset($_POST['checkbox_1'])){
     $c = $a;
   }
   else  if(isset($_POST['checkbox_2'])){
     $c = $b;
   } else if(isset($_POST['checkbox_1']) && isset($_POST['checkbox_2'])){
    if(count($a) == count($b)){
      for($i=0;$i<count($a);$i+}){
        $c[]=$a[i] + $b[i];
      }
   }
   }else{
    echo 'Error Contact Admin';
   }

?>