I need to combine two PHP associative array values into one. Consider this code:
$period['duration'] = "35";
$period['timeunit'] = "Years";
print_r($period);
Outputs:
Array
(
[duration] => 35
[timeunit] => Years
)
But what I need to end up with is just:
Array
(
[duration] => 35 Years
)
I've searched the documentation for this but can only find how to merge whole arrays or append new keys to the array etc.
This is because I have a HTML form that has a text field for the number, then a drop down for the unit (e.g years, months etc.)
I can't see a plain HTML way of combining two separate input fields before submitting via POST, otherwise I'd do that. I'm assuming PHP processing the post values afterwards is preferable to pre-processing with javascript.