如何将2个数组作为参数从控制器传递到视图

I am working with the zend framework and am trying to create an edit contacts page. When the page loads I want to display a form with the current stored values for those fields.

I am trying to pass a form and the database values to my view so that I can pre-populate the form with the current values for those fields. I can pass the form or the array of contacts. But when I try to pass both one of the arrays will return null

public function editContactAction()
{
    $form = new EditContact();
    $id = $this->params()->fromRoute('contactId');

    $variables = array();
    $contactService = $this->getServiceLocator()->get('User\Service\UserService');

    $variables['contacts'] = $contactService->editContact($id);

    return new ViewModel(array('form' => $form), $variables);
}

Very simple. The ViewModel argument is an array, pass your $variables array in the arguments array:

public function editContactAction()
{
     $form = new EditContact();
     $id = $this->params()->fromRoute('contactId');

     $variables = array();
     $contactService = $this->getServiceLocator()->get('User\Service\UserService');

     $variables['contacts'] = $contactService->editContact($id);

     return new ViewModel(array(
         'form' => $form,
         'variables' => $variables
     ));
}

And in your view, you can access this $variables array this way:

$this->variables ;