"Array to string conversion" in PHP — What It Means and How to Fix It

What the PHP error "Array to string conversion" means and how to fix it.

Published November 1, 2026

You used an array where PHP expected a string, for example in echo or string concatenation. PHP outputs the word 'Array'.

What it means and why it happens

This usually means a variable you thought was a string is actually an array, such as multiple checkbox values or a decoded JSON field.

Read the full message: it names the file and line where the problem was detected, which is the best place to start.

What you see

run the code
Warning: Array to string conversion in view.php on line 9

Practical examples

Code that triggers it

<?php
$tags = ['php', 'sql'];
echo 'Tags: ' . $tags;

The fix

<?php
echo 'Tags: ' . implode(', ', $tags);
// debugging: print_r($tags); var_dump($tags);

Debug the value

echo '<pre>'; var_dump($tags); echo '</pre>';

Common mistakes

  • Printing arrays directly.
  • Misreading a form field as scalar.
  • Using array in SQL string concatenation.

Key takeaways

  • Array to string conversion: You used an array where PHP expected a string, for example in echo or string concatenation.
  • Read the message and the line number first.
  • Fix the cause, don't just silence the error.

FAQ

How do I print an array?

implode() for lists, json_encode() or print_r() for debugging.

How do I find which line caused Array to string conversion?

The error message and stack trace show the file and line; start there and work backwards.

More PHP articles