I'm looking for a way to access an array defined in an included PHP file, from outside this file. I've been Googling on that for a few hours but I didn't really find anything that answered my question. I've tried using $GLOBAL['varname'] outside my script after using global $varname in the included file but it doesn't seem to work, got to say I'm a bit confused.
Is there any way I can do this in PHP?
Thanks a lot for the answer!
user $_SESSION
variables. so you will be able to access your variables anywhere in your php application.. untill you unset
it..
try this..
session_start();
$_SESSION['array'] = $array; //your array
now you can use this variable/array in any file of your project..
print_r($_SESSION['array']);
if you include a file in PHP you can access the variable the same way you would if it was in the same file..
File1 (foo.php):
<?php
$var = array('foo','bar');
File2:
<?php
require_once('foo.php');
print_r($var);
does this not work..?