Problem with array and variables as index

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

i have a problem determining a matrix value by using a variable as
index of the array.:
I'm using php 4.3.11 + win xp SP2 + apache 1.3.33
I wrote a class in which there is an array defined as follows. There is
also a method to get the value of a given element of the array.

class obj1 {

foerach (...) {
$this->_rows[] = array($key=>$value);

function _foo ($key, $offset=0) {
        return $this->_rows[$offset][$key];


Then, I have another class which contains an istance of obj1 and a kind
of wrapper to the _foo method:

class obj2 {
        $this->obj =& new obj1;

function bar ($key, $offset=0) {
//eg. key='test' offset=0
        echo $this->obj->_foo($key, $offset);


If I call the bar('test') method I get a NULL value, but if in the _foo
method i put echo $key.$offset it prints correctly 'test0'. Also, if I
put in _foo echo $this->_rows[0]['test'] it prints the correct value,
BUT if I echo $this->_rows[$offset][$key] it prints nothing!!
I can't understand where the problem is.... is it a bug?

Thanks for your answers!

Site Timeline