Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$games = ['W', 'L', 'L','W','W', 'L','W','W','W', 'L', 'L','W', 'L', 'L', 'W','W'];
$wins = 0;
$max_wins = 0;
foreach($games as $g) {
if ($g == 'W') {
$wins++;
$max_wins = max($max_wins, $wins);
} else {
$wins = 0;
}
}
printf("Max continious wins is: %d", $max_wins);