PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?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);
Show:  
Copy Clear