I have an array:
$record = array(Won,Lost,Won,Won,Lost);
I want to count the number of wins and losses in the array.
So everytime it finds "Won" in the array, do a $won++, and the same for loss, $loss++
I want to print out the record after that is completed.
print $won.' - '.$lost;
I think I figured it out, revisions to make this more efficient, will be appreciated.
<?php
$won = 0;
$lost = 0;
foreach ($record as $i => $value) {
if($value == "Won") {
$won++;
} elseif($value == "Lost") {
$lost++;
}
}?>