<?php
/**
* function to remove duplicates from array and also remove all nulls with comments with comments
* @param array $array Array to remove duplicates from
* @return $array
*/
function removeDuplicates($array) {
// remove duplicates from array
$array = array_unique($array);
// remove all nulls from array
$array = array_filter($array, function($value) { return $value !== null; });
// return the array
return $array;
}
//example
$result = removeDuplicates(['a', 'b', 'c', 'a', 'b', 'c', null]);
//output
echo $result; //['a', 'b', 'c']
For further actions, you may consider blocking this person and/or reporting abuse
Oldest comments (0)