note 68515 added to function.define
| From: | php-general at lists dot php dot net | Date: | Mon, 31 Jul 2006 06:26:59 +0000 |
| Subject: | note 68515 added to function.define | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115366@lists.php.net to get a copy of this message | ||
I typically use serialize() to store arrays in constants.
<?php
$value = array('Jim','Bob','Rebecca','Cooter');
define('CONSTANT',serialize($value));
?>
And unserialize as needed.
<?php
$name = 'Bob';
if(in_array($name,unserialize(CONSTANT)))
{
# Do something
}
?>
Didn't see this mentioned here - simple approach, allows for constant arrays without a ton of
overhead.
----
Server IP: 216.194.113.175
Probable Submitter: 69.54.3.168
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.define.php
Edit -- https://master.php.net/note/edit/68515
Del: integrated -- https://master.php.net/note/delete/68515/integrated
Del: useless -- https://master.php.net/note/delete/68515/useless
Del: bad code -- https://master.php.net/note/delete/68515/bad+code
Del: spam -- https://master.php.net/note/delete/68515/spam
Del: non-english -- https://master.php.net/note/delete/68515/non-english
Del: in docs -- https://master.php.net/note/delete/68515/in+docs
Del: other reasons-- https://master.php.net/note/delete/68515
Reject -- https://master.php.net/note/reject/68515
Search -- https://master.php.net/manage/user-notes.php