Resolve the nested variables.

Look for ${varname} patterns in the variable value and replace with an existing
environment variable.

This was borrowed from the excellent phpdotenv with very few changes.
https://github.com/vlucas/phpdotenv

@param $value

@return string