-1

Here is the Array im working with

[container:protected] => Array
  (
   [campaigns] => Array
    (
     [0] => Array
      (
       [id] => 1
        [name] => Merry Christmas
        [type] => classic
        [status] => draft
        [sender] => stdClass Object
        (
         [name] => Prebic
         [id] => 1
         [email] => prebic@balworld.in
         ))
    [count] => 1
    )
)

and Printing the Same in HTML Table using

<?php foreach($result['campaigns'] as $bw_campaigns): ?>
<tr>
<td><?php echo $bw_campaigns['name'] ?></td>
<td><?php echo $bw_campaigns['type'] ?></td>
<tr>
<?php endforeach; ?>

How can i print the value inside [sender] array ?

Bal Sankar
  • 17
  • 1
  • 5

2 Answers2

-1

Try:

<td><?php echo $bw_campaigns['sender']->name ?></td>
<td><?php echo $bw_campaigns['sender']->id ?></td>
<td><?php echo $bw_campaigns['sender']->email ?></td>

And sender is not an array, is an object.

MR Mark II
  • 433
  • 3
  • 13
-1

Noticing that the sender is actually stdClass, its members should be accessed with the following syntax:

$obj->member

Therefore, to get the value in sender, just do

<td><?php echo $bw_campaigns['sender']->name ?></td>
...
Siger
  • 1
  • 1
  • 4