note 48643 deleted from function.define by tularis
| From: | tularis@php.net | Date: | Sun, 03 Jun 2007 09:42:21 +0000 |
| Subject: | note 48643 deleted from function.define by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127157@lists.php.net to get a copy of this message | ||
Note Submitter: technopasta at yahoo dot com dot au
----
You can't use arrays in constants, so I came up with this two line function to get around it.
<?php
function const_array($constant) {
$array = explode(",",$constant);
return $array;
};
?>
So now if you define a constant like
<? define('myconstant','item1,item2,item3') ?>
and then use my function
<? $myarray = const_array(myconstant); ?>
$myarray will now contain an array with
item1
item2
item3
Hope this is useful for someone...