Collecting form errors to be displayed I have a piece of code that get errors from form and display to view:

$errors = $form-&gt;getMessages();
$msg = '';
foreach ($errors as $error)
{
    foreach ($error as $err)
    {
        $msg .= $err . '&lt;br/&gt;';
    }
}
$this-&gt;view-&gt;error_message = $msg;


It look so ugly, but now I don't have any ideas to improve it. Thank for help.
You can use array_merge to reduce the array from 2-dim to 1-dim, then implode the array.

$this-&gt;view-&gt;error_message = 
    implode(array_reduce($form-&gt;getMessages(),
                         "array_merge", 
                         array()),
            "&lt;br/&gt;");


http://php.net/manual/en/function.array-merge.php

http://www.php.net/manual/en/function.array-reduce.php