String to object path

I have a series of values in an array. The key will be something like “Header->header1” and “Header->header2”. The values for these would be ‘Val1’ and ‘Val2’ respectively. What I need to do is to put these in to a $params object to pass via a SoapClient.

Usually I’d do something like:

$client = new SoapClient($wsdl, $newheaders);
$params->Header->header1 = 'Val1';
$params->Header->header2 = 'Val2';
$params->Body->val3->val3.2->val3.2.1 = 1;

How can I do this using the array key if it is “val3->val3.2->val3.2.1”? I’m trying what seems obvious to me, but I’m ending up getting more like:

$params->Body->“val3->val3.2->val3.2.1” = 1;

instead of

$params->Body->val3->val3.2->val3.2.1 = 1;

Which is not what I want. Any ideas? I thought this would be simple by processing an array to the “val3->val3.2…” string, but it’s not worked how I wanted it to. Help!