How to solve PHP error 'Notice: Array to string conversion in…'

后端 未结 5 1430
执念已碎
执念已碎 2020-11-22 12:52

I have a PHP file that tries to echo a $_POST and I get an error, here is the code:

echo \"\";
echo \"\";
for($i=0; $i&l         


        
5条回答
  •  感情败类
    2020-11-22 13:55

    When you have many HTML inputs named C[] what you get in the POST array on the other end is an array of these values in $_POST['C']. So when you echo that, you are trying to print an array, so all it does is print Array and a notice.

    To print properly an array, you either loop through it and echo each element, or you can use print_r.

    Alternatively, if you don't know if it's an array or a string or whatever, you can use var_dump($var) which will tell you what type it is and what it's content is. Use that for debugging purposes only.

提交回复
热议问题