note 83954 deleted from function.define by cmb
| From: | cmb@php.net | Date: | Sun, 06 Oct 2019 07:52:55 +0000 |
| Subject: | note 83954 deleted from function.define by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212478@lists.php.net to get a copy of this message | ||
Note Submitter: thscheer at web dot de
----
How to define an array as constant with define?
there is a simple way to define an array of values as constant...
just
define ("constant-name","value1,value2,value3,value4");
$t_array = preg_split('/,/', constant(constant-name), -1, PREG_SPLIT_NO_EMPTY);
var_dump($t_array);
array(4) { [0]=> string(6) "value1" [1]=> string(6) "value2" [2]=>
string(6) "value3" [3]=> string(6) "value4" }
Now you can iterate over the array defined as constant ...