Actually i want to add both the values of ids 2 and the ids 3
<form method="post" name="fo" action="#">
<input type="text" name="ids[]" value="2"/>
<input type="text" name="amount[]" value="100"/>
<input type="text" name="ids[]" value="3"/>
<input type="text" name="amount[]" value="200"/>
<input type="text" name="ids[]" value="2"/>
<input type="text" name="amount[]" value="300"/>
<input type="text" name="ids[]" value="3"/>
<input type="text" name="amount[]" value="50"/>
<input type="submit" name="submit"/>
</form>
<?php
$id=$_POST['ids'];
$am=$_POST['amount'];
$arr=array(
array('id'=> $id,'am'=>$am)
);
$heads = array();
$amounts = array();
$i = 0;
foreach($arr as $sub)
{
$key = array_search($sub['id'], $heads);
if($key)
{
$amounts[$key] += $sub['am'];
}
else
{
$heads["'" . $i . "'"] = $sub['id'];
$amounts["'" . $i . "'"] = $sub['am'];
$i++;
}
}
print_r($heads);
print_r($amounts);
}
?>