Reputation: 10575
when i say
var_dump($this->variables['DEFAULTS_VALUES']);
I get the Following array
array(1) {
["ABE LOB RPT"]=>
string(8) "BEST2"
}
how do i get the value ["ABE BBB CCC"]
from this array
when i say in this way $this->variables['DEFAULTS_VALUES'][0]
It says UNDEFINED OFFSET: 0
.how do i get the value ["ABE BBB CCC"]
from this array
Upvotes: 0
Views: 120
Reputation: 86506
You're getting "undefined offset" errors because there's no value at index 0 in that array. PHP arrays are actually "ordered maps", and what looks like the first value here is actually a key -- $this->variables['DEFAULTS_VALUES']['ABE LOB RPT']
would give you back 'BEST2'.
If you actually want the keys, the array_keys
function would give them to you. Or you could use a foreach loop:
foreach ($this->variables['DEFAULTS_VALUES'] as $key => $value)
{
print "$key: $value<br>\n";
}
In your case, the one and only time through the loop would print out "ABE LOB RPT: BEST2".
Upvotes: 3
Reputation: 382626
Your array is associative array you need this:
echo $this->variables['DEFAULTS_VALUES']['ABE LOB RPT']; // BEST2
Upvotes: 0