Blog
Fetching Values of a PHP ENUM as an Array
To retrieve all values of a PHP ENUM as an array, the following line of code can be used:
$values = array_column(PageStatus::cases(), 'value');
In this example, the enumeration is named PageStatus
. By using array_column
, all value
values will be output as an array.