This I believe is a little harder than the title makes it sound, but I could be completely wrong. I have an array like this:
[["londrina",15],["cascavel",34],["londrina",23],['tiradentes',34],['tiradentes',21]]
I want to be able to take the common values, in this case londrina and tiradentes, and add the numbers together. My PHP code is the following:
$qry = mysql_query("SELECT * FROM bap WHERE semana = '".$week."'");
$rows = array();
while($row = mysql_fetch_array($qry)) {
$rows[] = $row;
}
$resultstr = array();
foreach($rows as $row) {
$resultstr[] = '["'.$row['zona'].'",'.$row['numero'].']';
}
$result = implode(', ',$resultstr);
print '['.$result.']';
I'm not sure if any more info is needed. The array is being outputted in this format to use for a jquery json graphing plugin. Let me know if anymore info is needed.