Hello to everybody !
I would like to create an array to store some data in.
Is there any way to keep the array visible (global) ?
Thanks in advance...
[Solved] Array...
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
If you keep the array within a file that is included on all of the pages, yes.
It's often done for configuration settings.
eg.
on all your pages
Note: in functions you need to just go global $config, and not global $config['admin'] to access a variable. 
It's often done for configuration settings.
eg.
Code: Select all
<?php
// config.inc.php
$config['admin'] = "root";
$config['slogan'] = "fear me for i am root!";
?>Code: Select all
<?php
include ("config.inc.php");
echo $config['admin'];
?>