在数组名称相同的价值

编程入门 行业动态 更新时间:2024-10-20 20:51:45
本文介绍了在数组名称相同的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要检查是否有与数组名称相同的值,如果存在具有相同名称的价值,我怎样才能得到它。比方说,我有

I want to check is there a value with same name in array, if there is a value with same name, how can i get it. Let's say i have

<?php if (is_array(Yii::app()->session['cart_values'])) { foreach ( Yii::app()->session['cart_values'] as $value) { ?>

和下一步是什么,再通过包含$文件名,并检查它是否存在具有相同名称的文件,另一个数组去了。

and what is next, again go through another array which contain $files name and check it if there is file with same name.

我尝试一些解决方案,但没有得到它。

I try few solutions but not get it.

感谢

推荐答案

尝试smething这样

Try smething like this

<?php if (is_array(Yii::app()->session['cart_values'])) { foreach ( Yii::app()->session['cart_values'] as $values) { // get the uniques (assuming that $values is an array) $uniques = array_unique($values); // get the common values on each arrays so you get the repeated values $union = array_diff($values, $uniques); } } ?>

希望这有助于。

更多推荐

在数组名称相同的价值

本文发布于:2023-07-28 02:36:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1226512.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   名称   价值

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!