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

Removing duplicate elements from PHP array

WBOY
WBOYOriginal
2016-08-08 09:30:281428browse

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.

Statement:
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