views:

73

answers:

1

Hey I have this kinda structure in my ini file I want to be able parse a variable inside a variable value

site.url = "www.example.com"
site.url.images = site.url "/images"

However, site.url is not parsed inside the site.url.images.

I am using zend config ini to parse my ini files. Is there a solution beside adding this feature myself?

+1  A: 

Zend_Config_Ini won't do that (since PHP's built-in parse_ini_file() won't do it).

So you'll have to work around it somehow.

The two approaches that seem obvious (to me):

  • Just don't do it. In your example, just set site.url.images to "images" and build the URLs in your application code (implement a nice little getUrlForImage($img) function that constructs the proper URL based on the config values and argument)

  • Extend Zend_Config_Ini to do some postprocessing.

In the latter case, you might be better off with something like:

site.url.image = "%%site.url%%/images"

Then walk the array of configuration values doing substitutions.

timdev