@rvazquezauthorMar 11.2008 — #Hope this contributes to clarify my point…
My file1.php initializes an array variable x. For example:
x[0] = 50; x[1] = 100; x[2] = 150;
But I want to access variable x from another file (file2.php) to perform further processing.
I can’t join content of both file1.php and file2.php into a single file, but instead, I have to use different files. So, I wonder how to access variable x, which is initialized in file1.php, from other file: file2.php.
Comments welcome,
Ruben
PS: In the previous post, I implicitly proposed a (potential) solution: using the output of file1.php as the input of file2.php –in case this can be done.
@TJ111Mar 11.2008 — #Make a test-script like this: [code=php] require("file1.php"); //initialized variable print_r($x); [/code] Using require makes sure that the file is included and the variable will be initialized. PHP parses included files in the order they are recieved, and treats them as inline scripts.
@TJ111Mar 11.2008 — #Its a PHP array, its just assigning them in associative key=>value pairs.
Here's a little example I ran in my PHP command-line debugger. <i> </i>$x = array("test"=>5, "example"=>6) : array = test: long = 5 example: long = 6 $x[0] : undefined = NULL $x['test'] : long = 5
Edit: Wow, I'm an idiot. Sorry Bokeh. His array would be a PHP array if he added $ before each x, he could of just left it out for example purposes.