Page 1 of 1

[Solved] Array...

Posted: Mon Dec 15, 2003 4:53 am
by dmakris
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...

Posted: Mon Dec 15, 2003 4:54 am
by malcolmboston

Posted: Mon Dec 15, 2003 4:58 am
by m3mn0n
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.

Code: Select all

<?php
// config.inc.php
$config['admin'] = "root";
$config['slogan'] = "fear me for i am root!";
?>
on all your pages

Code: Select all

<?php
include ("config.inc.php");

echo $config['admin'];
?>
Note: in functions you need to just go global $config, and not global $config['admin'] to access a variable. :)

re:

Posted: Mon Dec 15, 2003 5:01 am
by dmakris
Really thanks for your help guys.
Solved in minutes !