I have a function that I want to generate an array with. The format of the array is specific and only values need to be changed based on the arguments of my function. Here's the function:
function generatearray($name1, $field1, $name2, $field2) {
$language = ($user->language) ? $user->language : 'und';
$edit = array(
$name1 => array(
$language => array(
0 => array(
'value' => $field1,
),
),
), // ..... other elements $name2
);
return $edit;
}
$name2 and $field2 are optional arguments.
$useranywhere - you need to either pass it in as a parameter, or declare it as a global.