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.
var_dump($message)
to see what's in the array.Then
echo $message['keyYouNeedHere'];
to get it to output, obviously replacingkeyYouNeedHere
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!