<?php
function colorToStr(string $color): string {
    return match ($color) {
        "#f1edeb", "" => "white",
        "#ff00ff" => "pink",
        "#48bd8d" => "green",
        "#8200ff" => "lila",
        "#ff6700" => "orange",
        "#000000" => "black",
    };
}

function bg(string $bgColor, string $gridColor): string {
    if ($gridColor == "") $gridColor = "#8200ff";
    $bg = 'bg-' . colorToStr($bgColor) . '-' . colorToStr($gridColor);
    remember($bg);
    return $bg;
}

function remember(string $value): string {
    static $oldValue = "bg-white-lila";
    
    $copy = $oldValue;
    $oldValue = $value;
    
    return $copy;
}

function randomBg(): string {
    static $colors = ["#f1edeb", "#ff00ff", "#48bd8d", "#8200ff", "#ff6700"];
    $a = array_rand($colors, 2);
    return bg($colors[$a[0]], $colors[$a[1]]);
}