Skip to content

Color by code

PHP match expression

Flowchart (ISO 5807)

YesNoYesNoStartInput cc = 1Return «Червоний»Endc = 2Return «Зелений»EndReturn «Інший»EndFigure 1 — color

Source code

PHP
function color($c) {
    return match ($c) {
        1 => "Червоний",
        2 => "Зелений",
        default => "Інший",
    };
}

The editor opens with this code — change it and the chart redraws.

Language
PHP
Constructs
match expression
Topic
Switch / case
Formats
Word, Visio, draw.io, PDF, SVG

Related examples