- array_reverse: documentation ( source)
- array_shift: documentation ( source)
<?php
$arr = ["W", "L", "W", "W"];
$arr = array_reverse($arr);
$last = array_shift($arr); //Shift takes out the first element, but we reversed it, so it's last.
$counter = 1;
foreach ($arr as $result) {
if ($result != $last) break;
$counter++;
}
echo $counter;