Explode elements from mysql_fetch_array and sum them up
Am fetching memberID in form KE00033-00 where last two digits represent
number of individuals in the members family.So far am able to get all
memberID and explode them but am not able to sum them up. array_sum()
outputs a wrong value. Here is the code:
$query=mysql_query("SELECT * FROM subscribers");
$arr = array();
while($row=mysql_fetch_array($query)){
$arr[] =$row['member'];
}
foreach ($arr as $value)
{
$entries=explode('-',$value);
print_r($entries)."<br>";//outputs the last two digits of memberID's
echo array_sum($entries);
}
No comments:
Post a Comment