ConFoo Montreal 2026: Call for Papers

Voting

: five plus four?
(Example: nine)

The Note You're Voting On

anhaia dot gabriel at gmail dot com
11 months ago
If you want to get all the values of the Enum in a list of `string`, you might do something like this:

<?php

enum MyEnum: string
{
case
OPTION_A = 'option_a';
case
OPTION_B = 'option_b';
case
OPTION_C = 'option_c';

public static function
values(): array
{
return
array_map(fn ($case) => $case->value, self::cases());
}
}

?>

<< Back to user notes page

To Top