Ok, am trying to figure out the best way to do this. I have code as follows:
$context['dp_module_headers'] = array();
Than later on down within the function within a while loop I iterate through all foldernames and apply the path to this array. But the paths are relative to the folder names, so I need to include the folder names within the values of the exploded array.
$context['dp_module_headers'] += explode('+', $row[$type . '_header_files']);
This can return an array like so:
$context['dp_module_headers'][0] = 'source/script.js';
$context['dp_module_headers'][1] = 'source/script.css';
$context['dp_module_headers'][2] = 'source/script.js';
$context['dp_module_headers'][3] = 'mydir/style.css';
I need to pre-pend the folder name before all values within the array. I only have access to the folder name that it is in when within the function that does the explode. So within the other function of a different file, I don't have access to the folder name that these paths link to.
So, when doing the explode, I need to pre-pend the folders name before each path within the value of each array.
So, basically, this array needs to return the following instead:
$context['dp_module_headers'][0] = 'sitenews/source/script.js';
$context['dp_module_headers'][1] = 'sitenews/source/script.css';
$context['dp_module_headers'][2] = 'userpanel/source/script.js';
$context['dp_module_headers'][3] = 'userpanel/mydir/style.css';
I have a variable called $folder
that gets changed per explode
, but how can I add the $folder
name string variable to the beginning of each value while exploding it? Or is there a better way to do this?
Thanks guys :)