Home >Backend Development >PHP Tutorial >Removing duplicate elements from PHP array
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.