简体   繁体   English

PHP foreach 循环不同的数组

[英]PHP foreach loop different arrays

I have one array which I am looping with foreach and then within this loop I am looping another array.我有一个数组,我用 foreach 循环,然后在这个循环中我循环另一个数组。 I display the result but I get all values from the second array within each loop of the first....我显示结果,但我从第一个循环中的第二个数组中获取所有值....

So if I have 3 items from 1st array looping at 1st foreach will be displayed ok but in the part of the 2nd foreach, I will have repeated data from 2nd array, instead of single.因此,如果我在第一个 foreach 处循环的第一个数组中有 3 个项目将正常显示,但在第二个 foreach 的部分中,我将从第二个数组中重复数据,而不是单个数据。

Can you please assist, drive my thinking?你能帮忙吗,推动我的思考? Thank you谢谢

    "description": {
        "EN": {
            "headline": "artment in Malmö city",
            "summary": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,",
            "description": "Lorem Ipsum " 
        },
        "DA": {
            "headline": "3 værelses lejlighed i Malmø by",
            "summary": "Lorem Ipsum er simpelthen dummy tekst af t",
            "description": "Lorem Ipsum er simpelthen " 
        },

很明显,第二个 foreach 循环将在每次执行第一个 foreach 循环时完全执行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM