samer sboui
samer sboui

Reputation: 53

Get Array Element in Zend View

i pass an array to my view and i can't show element in my view ! THis is my array : Array ( [pin] => 00000 [card] => 00000 [status] => Y). thnx for helping me .

Upvotes: 0

Views: 133

Answers (1)

Gautam Rai
Gautam Rai

Reputation: 2505

suppose you have array

 $arrayData = array ( 'pin' => 00000, 'card' => 00000, 'status' => Y);

$viewModel = new \Zend\View\Model\ViewModel();

$viewModel->setVariables($arrayData);

Now, on view you can directly access as-

$pin, $card, etc

this will add a single varibale to the view-

 $viewModel->setVariable('testVar', 'abc');

on view page, just use as

 $testVar;

Upvotes: 1

Related Questions