'Notice: Array to string conversion in...' error

Updated: Jan 16, 2026
Version: 8.3
Owner: admin

The error means you are trying to use an array as though it's a string.

For example,

$var = [42]; echo "The Answer to the Ultimate Question of Life is $var";

will cause this error. To avoid that, you have to address a specific array item, for example

echo "The Answer to the Ultimate Question of Life is $var[0]";

The same goes for nested arrays. 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.