Home > Backend Development > PHP Tutorial > Removing duplicate elements from PHP array

Removing duplicate elements from PHP array

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-08 09:30:28
Original
1462 people have browsed it

Remove duplicate elements in the array:

1. Purely natural original method from data structure:

foreach($feerecord as $value)
{
$fee_record_id = $value['FeeRecordId '];
if(!in_array($fee_record_id,$fee_record_id_arr))
{
$fee_record_id_arr[] = $fee_record_id;
}
else
{
continue;
) y_column($feerecord, 'FeeRecordId ')));

3 function hints:

array_values($arr) returns all the values ​​in the array and establishes a numerical index array_unique($arr) The array is deduplicated, but the result key is returned There is no order in the values ​​array_column($arr,$key) takes out all the element values ​​​​with key value = $key in the multi-dimensional array and forms a numeric array


The above introduces the PHP array deduplication elements, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
How to create an array within an array?
From 1970-01-01 08:00:00
0
0
0
php array
From 1970-01-01 08:00:00
0
0
0
Array to array
From 1970-01-01 08:00:00
0
0
0
php array rotation
From 1970-01-01 08:00:00
0
0
0
array
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template