Fatal Error With The Arrays Under Yii 2.0

Hi,

The Yii doesn’t love me :). I think I will cheat on her with the raw PHP :).

So I’ve gotten this error: Error undefined offset:


 

    public function saveBettings() {

        $tippmixBettings = $this->fetchTippmix();

 

        foreach ($tippmixBettings as $tippmixBetting) {

           var_dump($tippmixBetting[10]); // Here the undefined offset error <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' />

 

            $betting = Betting::find()->where([

                'number'=>$tippmixBetting[0],

                'match_name'=>  utf8_decode($tippmixBetting[2]),



However it is very bizarre, because with raw PHP I found, and this is an exist array key…

Because the var_dump or print_r commands are working, this is how the $tippmixBetting looks like:




array (size=11)

  0 => string '007' (length=3)

  1 => string 'tenisz, ffi1' (length=12)

  2 => string 'F. Lopez - I. Karlovic' (length=22)

  3 => string '---' (length=3)

  4 => string '---' (length=3)

  5 => string '1.79' (length=4)

  6 => string '' (length=0)

  7 => string '0-2' (length=3)

  8 => string '' (length=0)

  9 => string 'Memphis' (length=7)

  10 => string 'tenisz, ffi' (length=11)



Here the part of the outputs:




string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'labdarúgás' (length=16)

string 'alpesi sí, női' (length=20)

string 'sífutás, női' (length=21)

string 'síugrás, ffi' (length=18)

string 'jégkorong, női' (length=20)

string 'jégkorong, női' (length=20)

string 'jégkorong, ffi' (length=17)



Why? There is the $tippmixBetting[10]… In raw PHP I have not gotten any notice…

Yii is php, so if you have an undefined offset - then something is wrong with your array, not with Yii.

It’s hard to tell what’s wrong with your code, probably fetchTippmix() is returning array of objects instead of array of array.

You should debug it for yourself.

Okay, you can delete this post. It is not Yii problem. My Apache or the PHP was the bad boy…

After there were other problems, I reinstall them and now they are working fine under Yii too. Sorry.

Sorry.