note 128817 added to class.unitenum

From: Date: Mon, 21 Aug 2023 23:46:36 +0000
Subject: note 128817 added to class.unitenum
Groups: php.notes 
Request: Send a blank email to php-notes+get-220779@lists.php.net to get a copy of this message
When looping through cases, you will need to access the values as an object and not an array, like this: <?php enum BlogStatus : string { case Published = "is_published"; case Draft = "is_draft"; case Scheduled = "is_scheduled"; } foreach (BlogStatus::case() as $datum){ echo $datum->name . '<br />'; // Published || Draft || Scheduled echo $datum->value . '<br />'; // is_publised || is_draft || is_scheduled } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 102.89.46.185) ---- Manual Page -- https://php.net/manual/en/class.unitenum.php Edit -- https://main.php.net/note/edit/128817 Del: integrated -- https://main.php.net/note/delete/128817/integrated Del: useless -- https://main.php.net/note/delete/128817/useless Del: bad code -- https://main.php.net/note/delete/128817/bad+code Del: spam -- https://main.php.net/note/delete/128817/spam Del: non-english -- https://main.php.net/note/delete/128817/non-english Del: in docs -- https://main.php.net/note/delete/128817/in+docs Del: other reasons-- https://main.php.net/note/delete/128817 Reject -- https://main.php.net/note/reject/128817 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220779) next »