note 48643 added to function.define

From: Date: Mon, 03 Jan 2005 01:55:52 +0000
Subject: note 48643 added to function.define
Groups: php.notes 
Request: Send a blank email to php-notes+get-82629@lists.php.net to get a copy of this message
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... ---- Manual Page -- http://www.php.net/manual/en/function.define.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48643 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48643&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48643&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48643&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48643&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48643&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48643&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48643&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82629) next »