To remove duplicate elements from an array:
1. Pure natural raw methods from data structures:
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
}
}
return $fee _record_id_arr;
Reasonable use of 2.PHP functions, code implementation needs: one line
$fee _recorda_id_arr = array_values (Array_unique (Array_column ($feerecord, ' feerecordid '));
3 Function Hints:
Array_values ($arr) returns all values in the array and establishes a numeric index
Array_unique ($arr) array is de-weighed, but the returned result key value is not in order
Array_column ($arr, $key) takes out the multidimensional array, the key value = $key all element values, and makes up a numeric array
The above introduces the PHP array to heavy elements, including the contents of the content, I hope the PHP tutorial interested in a friend helpful.