File: /home/awaldron/public_html/archive/voting_data/2015.php
<?php
$dat14 = file('2015.dat');
$i=-1;
$dat = array();
foreach ($dat14 as $l) {
if (strstr($l, "PENN HILLS WARD")) {
if ($i >= 0) {
$dat[$i]['turnout'] = number_format(($dat[$i]['ballots'] / $dat[$i]['voters'] * 100), 2);
$dat[$i]['dem_pct'] = number_format(($dat[$i]['straight_dem'] / $dat[$i]['voters'] * 100), 2);
$dat[$i]['rep_pct'] = number_format(($dat[$i]['straight_rep'] / $dat[$i]['voters'] * 100), 2);
}
$i++;
$dat[$i]['ward'] = substr($l,26,13);
}
if (strstr($l, "REGISTERED VOTERS - TOTAL")) {
$dat[$i]['voters'] = intval(substr($l,57,3));
}
if (strstr($l, "BALLOTS CAST - TOTAL")) {
$dat[$i]['ballots'] = intval(substr($l,57,3));
}
if (strstr($l, "Democratic (DEM)")) {
$dat[$i]['straight_dem'] = intval(substr($l,57,3));
}
if (strstr($l, "Republican (REP)")) {
$dat[$i]['straight_rep'] = intval(substr($l,57,3));
}
if (strstr($l, "Sara Jayne")) {
$dat[$i]['kuhn'] = intval(substr($l,57,3));
}
if (strstr($l, "DeSantis")) {
$dat[$i]['desantis'] = intval(substr($l,57,3));
}
if (strstr($l, "Palumbo")) {
$dat[$i]['palumbo'] = intval(substr($l,57,3));
}
if (strstr($l, "Underwood")) {
$dat[$i]['underwood'] = intval(substr($l,57,3));
}
if (strstr($l, "Rambo")) {
$dat[$i]['rambo'] = intval(substr($l,57,3));
}
if (strstr($l, "DeLuca")) {
$dat[$i]['deluca'] = intval(substr($l,57,3));
}
if (strstr($l, "Petrucci")) {
$dat[$i]['petrucci'] = intval(substr($l,57,3));
}
if (strstr($l, "Shealey")) {
$dat[$i]['shealey'] = intval(substr($l,57,3));
}
if (strstr($l, "Ferguson")) {
$dat[$i]['ferguson'] = intval(substr($l,57,3));
}
if (strstr($l, "Vecchio")) {
$dat[$i]['vecchio'] = intval(substr($l,57,3));
}
if (strstr($l, "Mowry")) {
$dat[$i]['mowry'] = intval(substr($l,57,3));
}
if (strstr($l, "Donald")) {
$dat[$i]['kuhnjr'] = intval(substr($l,57,3));
}
if (strstr($l, "Hoolahan")) {
$dat[$i]['hoolahan'] = intval(substr($l,57,3));
}
if (strstr($l, "Phifer")) {
$dat[$i]['phifer'] = intval(substr($l,57,3));
}
if (strstr($l, "Leon")) {
$dat[$i]['leon'] = intval(substr($l,57,3));
}
if (strstr($l, "Connor")) {
$dat[$i]['oconnor'] = intval(substr($l,57,3));
}
if (strstr($l, "Sepelyak")) {
$dat[$i]['sepelyak'] = intval(substr($l,57,3));
}
}
$totals = array();
foreach ($dat as $d) {
$totals['voters'] += $d['voters'];
$totals['ballots'] += $d['ballots'];
$totals['straight_dem'] += $d['straight_dem'];
$totals['straight_rep'] += $d['straight_rep'];
$totals['kuhn'] += $d['kuhn'];
$totals['desantis'] += $d['desantis'];
$totals['palumbo'] += $d['palumbo'];
$totals['underwood'] += $d['underwood'];
$totals['rambo'] += $d['rambo'];
$totals['deluca'] += $d['deluca'];
$totals['petrucci'] += $d['petrucci'];
$totals['shealey'] += $d['shealey'];
$totals['ferguson'] += $d['ferguson'];
$totals['vecchio'] += $d['vecchio'];
$totals['mowry'] += $d['mowry'];
$totals['kuhnjr'] += $d['kuhnjr'];
$totals['hoolahan'] += $d['hoolahan'];
$totals['phifer'] += $d['phifer'];
$totals['leon'] += $d['leon'];
$totals['oconnor'] += $d['oconnor'];
$totals['sepelyak'] += $d['sepelyak'];
}
$totals['turnout'] = number_format(($totals['ballots'] / $totals['voters'] * 100), 2);
$totals['dem_pct'] = number_format(($totals['straight_dem'] / $totals['voters'] * 100), 2);
$totals['rep_pct'] = number_format(($totals['straight_rep'] / $totals['voters'] * 100), 2);
echo '<pre>', print_r($totals), '</pre>';
?>