note 127226 added to language.types.enumerations
| From: | amx at main dot php dot net | Date: | Wed, 06 Jul 2022 11:39:43 +0000 |
| Subject: | note 127226 added to language.types.enumerations | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-218905@lists.php.net to get a copy of this message | ||
Easily iterate over all cases in an enum.
enum Status {
case Queued = 'queued';
case Running = 'running';
case Finished = 'finished';
case Failed = 'failed';
}
// Iterate using cases() which returns an array containing all cases
foreach (Status::cases() as $status) {
print $status . "\n";
}
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.133 (proxied: 2405:201:5504:f288:58b9:7fe3:8e1e:e76a)
----
Manual Page -- https://php.net/manual/en/language.types.enumerations.php
Edit -- https://main.php.net/note/edit/127226
Del: integrated -- https://main.php.net/note/delete/127226/integrated
Del: useless -- https://main.php.net/note/delete/127226/useless
Del: bad code -- https://main.php.net/note/delete/127226/bad+code
Del: spam -- https://main.php.net/note/delete/127226/spam
Del: non-english -- https://main.php.net/note/delete/127226/non-english
Del: in docs -- https://main.php.net/note/delete/127226/in+docs
Del: other reasons-- https://main.php.net/note/delete/127226
Reject -- https://main.php.net/note/reject/127226
Search -- https://main.php.net/manage/user-notes.php