可以将php循环功能转换为双桶系统吗?

Is there a simple way to modify this php:

function cycleCols() {
    $p = "transparent;";
    $s = "#efefef;";
    static $lastColour;
    $lastColour = ($lastColour == $p) ? $s : $p;
    return $lastColour;
}

To get it to cycle like this:

transparent;
transparent;
#efefef;
#efefef;
transparent;
transparent;
#efefef;
#efefef;

Etc, instead of how it does now..

transparent;
#efefef;
transparent;
#efefef;

Etc... or does something else entirely need to be built to do this?

function cycleCols() {
    static $colors = ['transparent;', '#efefef;'], $i = 0;
    $selectColor = ($i++/2 % 2 == 0) ? 0 : 1;
    return $colors[$selectColor];
}

Increment a counter ($i), divide it by 2, then check if it's even/odd.