forked from provisioner/Provisioner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.php
More file actions
28 lines (22 loc) · 723 Bytes
/
utils.php
File metadata and controls
28 lines (22 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/*
* Recursively merge two arrays, overwriting any keys that match with the second array
*/
function merge_arrays($new_array, $Arr2)
{
foreach($Arr2 as $key => $Value)
{
if(array_key_exists($key, $new_array) && is_array($Value))
$new_array[$key] = merge_arrays($new_array[$key], $Arr2[$key]);
else
$new_array[$key] = $Value;
}
return $new_array;
}
function import_settings($filename, &$settings) {
$tmp = json_decode(file_get_contents($filename), TRUE);
// TO DO: Loop through recursively the entire array and look for any "quantity" specifications. If they exist
// make copies of the items
$settings = merge_arrays($settings, $tmp);
return TRUE;
}