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. 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; } 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
Archived
This topic is now archived and is closed to further replies.