cheneymac Posted January 1, 2008 Share Posted January 1, 2008 There are multiple php arrays on my network that I would like to merge into a single array, but I am not sure how as they are all assigned to the same variable names. For instance file a.php contains only a multidimensional array: <?php $mocks = array(array(),array()); ?> Files b.php and c.php contain the exact same php code with different content stored in their arrays. I am including these files' contents into another file: xyz.php. In xyz.php how do I merge the array contents of a.php, b.php, c.php into a single array even though each of those three files assigns their respective arrays to the $mocks variable? Unfortunately, each of the included files is owned by a separate person, and so I cannot alter those files, such as changing the variable name to something unique, without crashing applications written by the file owners. Quote Link to comment https://forums.phpfreaks.com/topic/83911-how-to-merge-included-arrays-of-the-same-variable-name/ Share on other sites More sharing options...
sasa Posted January 1, 2008 Share Posted January 1, 2008 try $file_names=array('a.php','b.php','c.php'); $total = array(); foreach($file_names as $name){ include($name); $total[] = $mocks; } Quote Link to comment https://forums.phpfreaks.com/topic/83911-how-to-merge-included-arrays-of-the-same-variable-name/#findComment-427034 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.