开发者

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: 0

Any 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜