PHP – how to convert array of values to array with nested keys from values of first array? [closed]

I have this array:

$input = ['a', 'b', 'c', 'd'];

the output should be:

$output = convertArrayValues($input, 'final');

$output['a']['b']['c']['d'] = 'final;

I need code for convertArrayValues() method which will do the job of converting:

$input = ['a', 'b', 'c', 'd'];

into:

 $output['a']['b']['c']['d'] = 'final;

Dumped array input:

array:4 [
  0 => "a"
  1 => "b"
  2 => "c"
  3 => "d"
]

Dumped array output:

array:1 [
  "a" => array:1 [
    "b" => array:1 [
      "c" => array:1 [
        "d" => 'final
      ]
    ]
  ]
]