如何在PHP中获取foreach中的重复变量 [英] How to get repetitious variable in foreach at PHP

查看:86
本文介绍了如何在PHP中获取foreach中的重复变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在php中获取foreach中的重复变量:



我尝试过:



I want to get out Repetitious variables in foreach at php :

What I have tried:

foreach ($article->tags as $tags) {
            foreach ($tags->articles as $related_article) {
                echo $related_article->id . '||';
            }
        }



此代码告诉我:

298 || 301 || 303 || 303 | |

,你可以看到它有303和303.

我只想要其中一个或者没有一个。


This code give me this :
298||301||303||303||
and you can see , it`s have 303 and 303 .
I just want one of them or none of them.

推荐答案

article->标签 as
article->tags as


标签){
foreach


tags-> articles as
tags->articles as


这篇关于如何在PHP中获取foreach中的重复变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆