4

How to read an array declared in the application.ini file using zend_config object.

eg 1 : supported.prop[]="abc" supported.prop[]="def"

when I say $config->supported->prop, it returns zend_config object, while I was expecting an array to be returned.

eg 2: supported.prop="abc" This is straightforward though, where you say $config->supported->prop gives string "abc".

So, can someone help me with the eg 1 , where I am trying to read the array with zend_config object.

Thanks

krishna
  • 3,547
  • 5
  • 27
  • 29

2 Answers2

10

$config->supported->prop->toArray() will givie you an array.

Arek Jablonski
  • 349
  • 1
  • 7
3

Zend_Config implements the Iterator and Countable interfaces, so you can interact with an instance just like you would an array:

foreach ($config->supported->prop as $v){
    echo $v;
}

$count = count($config->supported->prop);
David Weinraub
  • 14,144
  • 4
  • 42
  • 64
  • I was looking for some sort of straightforward method that does it. Seems like this is the only way. Thanks for the answer – krishna May 30 '11 at 22:49