Instantiate dynamic array Magento
Kick me if I'm being silly but some s开发者_Go百科ome 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: 0Any ideas? Do I need to handle these arrays differently since they are in a class?
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.
精彩评论