# Warning: Array to string conversion

**Code:** `Array to string conversion` · **Category:** PHP · **Seen on:** PHP

An array was used where a string is expected — echoing it, concatenating it, or passing it to a string function.

## Meaning

PHP prints the literal word “Array”. Often a form field submitted as an array (`name="tags[]"`), a function returning an array, or debug output with echo instead of print_r.

## Common causes

- `echo $array` or `"text $array"`
- Form field with `[]` in its name
- Function returned an array where you expected a string
- Passing an array to htmlspecialchars/strlen

## Quick fix

1. Use `implode(', ', $array)` to join
2. Use `print_r`/`var_dump`/`json_encode` for debugging
3. Check form field names

## Detailed fix by platform

### PHP

1. `echo htmlspecialchars(implode(', ', (array) $_POST['tags']));`

## How to diagnose

1. **Value** — var_dump() it — what does the array contain?
2. **Intent** — Join, pick one element, or encode?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/php/array-to-string-conversion)
