views:

57

answers:

2

Kick me if I'm being silly but some some reason I'm having a heck of time building a dynamic array in magento.

Example:

$data = array();

$data[0] = 'test';
$data[1] = 'what';

I keep getting an ERROR:
Notice: Undefined offset: 0

Any ideas? Do I need to handle these arrays differently since they are in a class?

+1  A: 

I dropped the following code into a controller action

        $data = array();            
        $data[0] = 'test';
        $data[1] = 'what';
        var_dump($data);

And got the following Notice free output

array
  0 => string 'test' (length=4)
  1 => string 'what' (length=4)

So your problem is elsewhere. There's probably somewhere else in your code where you're referencing

    $data[0]

in a non-assignment operator way. That's why you're getting the Notice.

Alan Storm
A: 

I appreciate your comments. I ended up going about a different route.

Tegan Snyder