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 请问各位,如何在Jetson nano主控板的Ubuntu系统中安装PyQt5
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来
  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
  • ¥15 安装ubantu过程中第一个vfat 文件挂载失败
  • ¥20 GZ::CTF如何兼容一些靶机?
  • ¥15 etcd集群部署问题
  • ¥20 谁可以帮我一下问一下各位
  • ¥15 为何重叠加权后love图的SMD与svyCreateTableOne函数绘制基线表的不一致
  • ¥150 求 《小魔指》街机游戏机整合模拟软件