如何';回声&x27;Php中的多维数组?
这是我正在使用的阵列如何';回声&x27;Php中的多维数组?,php,arrays,Php,Arrays,这是我正在使用的阵列 [container:protected] => Array ( [campaigns] => Array ( [0] => Array ( [id] => 1 [name] => Merry Christmas [type] => classic [status] => draft [sender] => s
[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
)
)
并使用
<?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; ?>
如何在[sender]数组中打印值?试试:
<td><?php echo $bw_campaigns['sender']->name ?></td>
<td><?php echo $bw_campaigns['sender']->id ?></td>
<td><?php echo $bw_campaigns['sender']->email ?></td>
发送方不是数组,而是对象。注意到
发送方
实际上是stdClass
,应使用以下语法访问其成员:
$obj->member
因此,要获得sender中的值,只需执行以下操作
<td><?php echo $bw_campaigns['sender']->name ?></td>
...
...