Are there any built-in functions in PHP for inverting colors, or is creating a custom function the only option?

There are no built-in functions in PHP for inverting colors. To invert colors, you would need to create a custom function that takes the RGB values of the color and calculates their inverted values. This can be achieved by subtracting each RGB value from 255 to get the inverted color.

function invertColor($color) {
    $r = 255 - $color[0];
    $g = 255 - $color[1];
    $b = 255 - $color[2];
    
    return [$r, $g, $b];
}

$color = [100, 150, 200];
$invertedColor = invertColor($color);

echo "Original Color: " . implode(",", $color) . "<br>";
echo "Inverted Color: " . implode(",", $invertedColor);