Jarid Posted August 10, 2010 Share Posted August 10, 2010 Here is a section of php file A include_once(dirname(__FILE__) . '/PhpfileB.php') $VALID_RATING_IDS = $Ratethese Here is all of php file B $Ratethese = "array("1", "2",);" I need the var $VALID_RATING_IDS to = $Ratethese from file B I am trying to include an array from php file B in php file A. Is this possible? How can i accomplish this? Quote Link to comment Share on other sites More sharing options...
freeloader Posted August 10, 2010 Share Posted August 10, 2010 Once you included file B into file A, both of them are 'joined' together. Php will treat it like one big file. So yes, you should be able to just call upon the array in file B. Quote Link to comment Share on other sites More sharing options...
linus72982 Posted August 10, 2010 Share Posted August 10, 2010 I think you'll need to include: global $Ratethese; in your first file before you assign. Or maybe not, who knows, I've never been good at encapsulation and scope. Quote Link to comment Share on other sites More sharing options...
Jarid Posted August 11, 2010 Author Share Posted August 11, 2010 PhP File A include_once(dirname(__FILE__) . '/PhpFileB.php'); global $Ratethese; $VALID_RATING_IDS = $RATETHESE; Php File B $RATETHESE = "array("1", "2");" For some reason it is printing the array on the page, and the array is not being used to run the script. Did i do anything wrong? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.