Include arrays with the same name from different files in PHP? -
this question has answer here:
- php variables same name 2 answers
i trying figure out how can include arrays have same name php file 2 different files .
i know it's simple, can't seem find right search me solution.
i've been trying reference arrays such function_call(menu_config.$config)
isn't working.
assuming both files have $config
array. if want 1 resulting array:
include('file1.php'); $new = $config; include('file2.php'); $new = array_merge($new, $config);
or 2 new arrays:
include('file1.php'); $config_1 = $config; include('file2.php'); $config_2 = $config;
another option function:
function get_config($file) { include($file); return $config; } $config_1 = get_config('file1.php');
Comments
Post a Comment