function get_goal_count($id) { $a = 0; $b = 0; $events = get_ticker_events($id); foreach ($events as $event) { if ($event["action"] == "goal") { if ($event["team"] == 0) { $a++; } else { $b++; } } } return array("team_a" => $a, "team_b" => $b); }
<?php require_once "../php/main.php"; $id = argreq("id"); $events = get_ticker_events($id); if (is_null($events) || empty($events)) { api_error(); } api_done(array("events" => $events));