What PHP function can be used to remove duplicate values from an array?
When working with arrays in PHP, it is common to encounter duplicate values that need to be removed. To remove duplicate values from an array, you can use the `array_unique()` function in PHP. This function takes an array as input and returns a new array with only unique values, removing any duplicates.
// Original array with duplicate values
$originalArray = array(1, 2, 2, 3, 4, 4, 5);
// Remove duplicate values
$uniqueArray = array_unique($originalArray);
// Output the unique array
print_r($uniqueArray);
Related questions
-
PHP file paths fopen
-
JavaScript AJAX jQuery
-
file upload PHP script security measures