ERROR Array to string Conversion on line 28

Asked

Viewed 31 times

-1

I was watching a tutorial and the video of the instructor that was posted did not give this error, and now it is with me:

Array to string Conversion on line 28

I already looked for a solution and the videos told me to put one echo, but I already put it and it didn’t work.

private function GetLista(){
        $i = 1;
        while($lista = $this->ListarDados()):
        $this->itens[$i] = array(
            'cate_id' => $lista['cate_id'],
            'cate_nome' => $lista['cate_nome'],
            'cate_slug' => $lista['cate_slug'],
            'cate_link' => Rotas::pag_Produtos(). '/' .$lista['cate_id'] . '/' . ['cate_slug']
        );

        $i++;
        endwhile;
    }
  • Speak there, Still! In this question I edited to fix. For your next, read formatting. Another thing: the error occurs on line 28. But your code does not have 28 lines... How about pointing, in this code, which is line 28? ;D

  • Hello, sorry and I did not know the formatting, but in the next posts I will put :p

  • Taking a superficial look, I found a mistake here: 'cate_link' => Rotas::pag_Produtos(). '/' .$lista['cate_id'] . '/' . ['cate_slug']
. That part: ['cate_slug'] should be $lista['cate_slug'], nay?! :)

  • Hello, thank you that was the same mistake, unfortunately it was a mistake of mine at the time of typing, thank you for helping me, have any part of posting for beginners? Or I can publish in general?

  • The ideal is to do the [tour] and give a brief read on help center. If you’ve already found the problem, I’ll formulate an answer and we’ll call this one off. =)

  • 1

    Hello Still. I believe the @Lipespry-defolga- response is correct. If it has solved the problem, you are the only one able to approve it. See more here > https://pt.meta.stackoverflow.com/a/1079/15361

Show 1 more comment

1 answer

1

Look at that line:

'cate_link' => Rotas::pag_Produtos(). '/' .$lista['cate_id'] . '/' . ['cate_slug']

Failed to declare the array here: ['cate_slug']... See how it looks:

'cate_link' => Rotas::pag_Produtos(). '/' .$lista['cate_id'] . '/' . $lista['cate_slug']
  • 1

    I had just posted ... ^^

  • 1

    I only did a screening before, via comment. ;D

  • 1

    kkkk Ta certo! =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.