List Info

Thread: note 68515 added to function.define




note 68515 added to function.define
user name
2006-07-31 06:26:59
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  -- h
ttps://master.php.net/note/delete/68515/integrated
Del: useless     -- http
s://master.php.net/note/delete/68515/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/68515/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/68515
Reject      -- https://mast
er.php.net/note/reject/68515
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

note 68515 deleted from function.define by bjori
user name
2006-07-31 08:16:54
Note Submitter:  

----

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.

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )