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

发布于 2024-12-15 04:09:01 字数 1051 浏览 2 评论 0原文

这是来自这个<的附加问题/a>.

我有一个包含多个值和数组的数组。我知道我可以使用

$data['property'] = value;

And 因为我在将 $data 发送给它后就在视图中,所以我知道我可以

echo $PROPERTY; 

但是,这个数组还包含数组。

[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]...

[1] 包含多个 [TITRE]、[MESSAGE][DATE] 集的数组。现在,通过将此总数组发送到视图,我可以回显 $THREAD 之类的内容并获取正确的值。但是我应该如何继续访问每组的值呢?由于集合数组在 [1] 中,然后在 [0] 中,我真的不知道该怎么做。我不想重复 [TITRE],因为有不止一个 [TITRE],我想展示所有这些,而不仅仅是一个。我想做的是做这样的事情:

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

有什么线索可以提供帮助吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风流物 2024-12-22 04:09:01

不太确定你的意思,但如果你想对数组执行 foreach() ,你可以尝试

foreach ($array as $array => $subarray)
{
//code
}

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文