Justin John
Justin John

Reputation: 9635

Getting an error on accessing an array from ini file to zend framework

In my config.ini file given

customer.login.test = "test case" 
customer.login.support[] = "abel"
customer.login.support[] = "justin"
customer.login.support[] = "leon" 

I tried to access it in zend action helper function as

$config = \Zend_Registry::get("config");
echo $config->customer->login->test; // Outputs as "test case"

print_r($config->customer->login->support); // No Result

print_r($config->customer->login->support->toArray()); // Gives Error

ERROR: Call to a member function toArray() on a non-object

How to correct this problem?

EDIT:

support[] = "abel"
support[] = "justin"
support[] = "leon" 

In zend action helper function

print_r($config->support->toArray());

Above print_r statement gives me a correct array. How this happens?

Upvotes: 0

Views: 120

Answers (1)

ainokna
ainokna

Reputation: 865

I've just tried your code. It works fine. It looks like you don't set customer.login.support[].

This can happen if you load another section of config file (e.g. testing instead of development) which also have customer.login.test but doesn't have customer.login.support[]

Upvotes: 1

Related Questions