Reputation: 780
I pass an array to a view, which has code like this:
<?php foreach ($this->results as $r): ?>
<div>
<?php echo $this->url(array('id' => $this->escape($r[RecordID]) ....
Suppose I want to use object notation:
<?php foreach ($this->results as $r): ?>
<div>
<?php echo $this->url(array('id' => $this->escape($r->RecordID) ....
Is this possible?
Upvotes: 1
Views: 88
Reputation: 11853
Yes you can try with Object to use object array in view like
<?php foreach ($this->arrUserList as $data) { ?>
<?php $data = (object)$data; ?>
<td><?php echo $this->escape($data->userName); ?></td>
Let me know if i can help you more.
Upvotes: 1
Reputation: 24655
Your only real option is to cast the array to an object prior to using it this way.
<?php foreach ($this->results as $r): ?>
<div>
<?php $r = (object)$r;
echo $this->url(array('id' => $this->escape($r->RecordID) ....
Upvotes: 1