这样的二维数组合并并去掉重复值,该如何做
这样的二维数组合并并去掉重复值,该怎么做
这样的二维数组合并并去掉重复值(attr_id,attr_name,attr_value三个字段都相同的则保留一个去除一个)
- PHP code
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> Array ( [0] => Array ( [attr_id] => 16950 [attr_name] => 台式机CPU品牌 [attr_value] => AMD ) [1] => Array ( [attr_id] => 16951 [attr_name] => 台式机操作系统 [attr_value] => Linux ) ) Array ( [0] => Array ( [attr_id] => 16955 [attr_name] => 售后服务 [attr_value] => 一年 ) )
------解决方案--------------------
function array_multi_unique($ar) {
$ar = array_map('serialize', $ar);
$ar = array_unique($ar);
return array_map('unserialize', $ar);
}
print_r( array_multi_unique($a) );
------解决方案--------------------
在唠叨老大的基础上改改
- PHP code
<?php $new = Array ( '0' => Array ( 'attr_id' => '16950', 'attr_name' => '台式机CPU品牌', 'attr_value' => 'AMD', 'attr_type' => 1, 'belong' => 'goods_sku' ), '1' => Array ( 'attr_id' => '16951', 'attr_name' => '台式机操作系统', 'attr_value' => 'Linux', 'attr_type' => 2, 'belong' => 'goods_sku' ), '2' => Array ( 'attr_id' => '16955', 'attr_name' => '售后服务', 'attr_value' => '一年', 'attr_type' => 2, 'belong' => 'goods_sku' ), '3' => Array ( 'attr_id' => '16950', 'attr_name' => '台式机CPU品牌', 'attr_value' => 'AMD', 'attr_type' => 1, 'belong' => 'goods' ) ); // 老大的基础上改改 function array_multi_unique($ar, $filter=array()) { if(!empty($filter)) { $_v = array_fill_keys($filter, ' '); $_ar = array(); foreach($ar as $k => $v) { $_ar[$k] = array_intersect_key($v, $_v); } } else { $_ar = $ar; } $_ar = array_map('serialize', $_ar); $_ar = array_unique($_ar); $_ar = array_map('unserialize', $_ar); if(!empty($filter)) { return array_intersect_key($ar, $_ar); } else { return $_ar; } } print_r(array_multi_unique($new, array('attr_id', 'attr_name', 'attr_value'))); <div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

XREAL launched a new product - XREALBeamPro at the spatial computing new product launch conference, priced from 1,299 yuan. According to the official introduction, XREALBeamPro is a computing terminal that gradually releases 2D applications into 3D space. Equipped with XREALAR glasses, it will form a "complete consumer-grade AR space computing system" and minimize the migration cost of users from the mobile phone side. In terms of design, XREALBeamPro looks like a smartphone, but it is not a mobile phone product, but a spatial computing terminal equipped with a touch display. It is officially positioned as an “AR spatial computing terminal like a Phone”. At the press conference, XREAL founder and CEO Xu Chi expressed his enthusiasm for BeamPro’s capabilities.

With the development of AR (Augmented Reality) and VR (Virtual Reality), these two technologies have become an important part of innovation and experience. With the popularity of PHP as a network programming language, PHP has become a feasible choice for developing AR/VR applications. This article will introduce how to use PHP to build AR/VR applications. 1. Understand AR and VR technologies Before we start creating AR/VR applications, we need to understand the different technologies and libraries. AR technology allows virtual objects or information to interact with real-world environments. V

(Nweon September 26, 2023) Microsoft believes that MicroLED has the characteristics of small size, light weight, high brightness, and high packaging density, and may be particularly suitable for head-mounted devices that require high resolution, small size, and light weight. monitor. In a patent application titled "Microlenses providing wide range chief ray angle manipulation for panel display", Microsoft introduced a microlens that provides wide range chief ray angle manipulation for panel display, and a display system configured with the microlens array. Wherein, each microlens in the array corresponds to a respective pixel of the panel display. Microlenses are configured according to their

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

From January 9th to 12th, more than 4,000 exhibitors gathered at CES, the consumer electronics "Spring Festival Gala". As an innovative company in the field of consumer AR, Mojie Technology participated in CES for the first time, fully demonstrating the strong strength of Chinese AR companies in core devices, complete machine solutions and customized services. At the Mojie booth, the AR glasses based on binocular resin diffraction light waveguide + MicroLED were displayed, which aroused the interest of many visitors, who tried them on and experienced their functions. This AR glasses has many practical features. First, the wearer can view the text content in real time through the glasses lens, which makes reading more convenient. Secondly, the glasses have built-in microphones that can collect voice information and convert it into text in the specified language through the instant translation function.

NTT QONOQ Devices has unveiled the Mirza wireless XR glasses for smartphones, freeing users from needing to wrangle cords. The glasses can display virtual AR content in real-world spaces like Pokemon Go or their phone content on a large virtual displ

As a technology company driven by innovation, Christie is able to provide comprehensive solutions, rich industry experience and a complete service network in intelligent audio-visual technology. At this year's InfoCommChina, Christie brought RGB pure laser projectors, 1DLP laser projectors, LED video walls, and content management and processing solutions. At the event site, a large-scale customized outer spherical dome specially designed for astronomical displays became the focus of the scene. Christie named it "Sphere Deep Space", and the Christie M4K25RGB pure laser projector gave it "green vitality" . Mr. Sheng Xiaoqiang, senior technical service manager of the Commercial Business Department in China, said: It is not difficult to realize an outer spherical dome projection, but it can be made smaller and the color
