notice: array to string conversion in php

后端 未结 2 2062
被撕碎了的回忆
被撕碎了的回忆 2021-02-10 09:53
prepare(\"SELECT p_id FROM players_to_team WHERE t_id = ?\");

    $t         


        
相关标签:
2条回答
  • 2021-02-10 10:20

    Try replacing $player[] = array(); by $player = array(); at the beginning (line 2).

    This is because that you declare an array at the index 0 of this variable which is told to be an array because of the []. You therefore try to place an array in your array, making it multidimensional.

    0 讨论(0)
  • 2021-02-10 10:33

    You cannot simply echo an array. echo can only output strings. echo 'foo' is simple, it's outputting a string. What is echo supposed to do exactly in the case of echo array('foo' => 'bar')? In order for echo to output anything here, PHP will convert array('foo' => 'bar') to a string, which is always the string "Array". And because PHP knows this is probably not what you want, it notifies you about it.

    The problem is you're trying to treat an array like a string. Fix that.

    0 讨论(0)
提交回复
热议问题