get zend FlashMessenger message as string

174 views Asked by At

I have following code in controller as below:

public function indexAction(){
   $this->flashMessenger()->addMessage('hi');
}

In view page :

$messages = $this->flashMessenger()->getMessages();
            foreach($messages as $message) {
                echo $message.' ';
            }

as above code is working, but flashmessenger returns array. I want something that could return strings only.

1

There are 1 answers

0
delboy1978uk On BEST ANSWER

var_dump($message) to see what's in the array.

Then echo $message['keyYouNeedHere']; to get it to output, obviously replacing keyYouNeedHere with the actual array key index.

Also, read up the documentation here https://framework.zend.com/manual/2.3/en/modules/zend.view.helpers.flash-messenger.html

Without your loop, you can use the helper like so:

echo $this->flashMessenger()->render();

You can also edit the HTML markup that gets generated to suit. Look into it!