Why does this PHP code just echo “Array”?

You are calling echo on an actual array, which does not have an implicit string representation.

In order to output an array’s contents you can use the print_r, var_dump or var_export functions or for custom output, you can use array_map or even a foreach loop:

print_r($errormessage);
var_dump($errormessage);
var_export($errormessage);

foreach($errormessage as $error) 
   echo $error . '<br/>';

array_map('echo', $errormessage);

Leave a Comment