initializing same array across web pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sunnyment
Forum Newbie
Posts: 1
Joined: Sun Mar 06, 2011 3:16 pm

initializing same array across web pages

Post by sunnyment »

i have a large array (1000 to 2000 elements) where each element has a unique value.
I need to reference this array in each web page.
My plan was to assign all the array elements in a file then include it in each page.

But it seems like this would take up a lot of processing when it repeats the array assignment for each page.
Is there a more efficient way to do this in php?

thanks in advance. :)
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: initializing same array across web pages

Post by internet-solution »

You can load the array in a Session variable.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: initializing same array across web pages

Post by AbraCadaver »

internet-solution wrote:You can load the array in a Session variable.
Yes, but then there would be a copy of this array for every single user. Just include the file.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply