duanhuang1967 2011-11-13 19:23
浏览 29
已采纳

在PHP视图中访问数组中的数组

This is an additional question from this.

I have this array containing multiple values as well as arrays. I know that I can use

$data['property'] = value;

And since I'm in the view after sending the $data to it, I know I can

echo $PROPERTY; 

However, this array also contains arrays.

[0] => Array ( [CSS] => css/style_centre_paiement_paiements_1.css [PAGE_NAME] =>
ACCUEIL [RANK] => PARENT [THREAD] => Accueil [FULL_NAME] => Marc Bélanger [C1] => Accueil
[C2] => Inscription - Enfant
[C3] => Centre de Paiement
[C4] =>Nous contacter
[C5] =>Votre compte
[C6] => 
[C7] =>Déconnexion
)[1] => Array ( [0] => Array ( [TITRE]...

The [1] contains an array of several [TITRE],[MESSAGE][DATE] sets. Right now, by sending this total array to the view, I can echo things like $THREAD and get the correct value. But how should I proceed to access the value of each of my sets ? Since the array of sets is in [1], then [0], I don't really know how to do it. And I don't want to to echo [TITRE] because there is more than one [TITRE] and I want to show them all, not just one. What I would like would be to do something like this :

foreach ($alert as $row)
    {
      ....
    }

Any clue how to help ?

  • 写回答

1条回答 默认 最新

  • du5739 2011-11-13 19:30
    关注

    Not really sure what you mean, but if you want to do a foreach() with an array you could try

    foreach ($array as $array => $subarray)
    {
    //code
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂