In PHP, how do I deduplicate strings with strong typing?

PHP, deduplicate strings, strong typing, array manipulation

This example demonstrates how to remove duplicate strings from an array in PHP while using strong typing for function parameters.

<?php function deduplicateStrings(array $input): array { return array_values(array_unique($input)); } // Example usage $strings = ["apple", "banana", "apple", "orange", "banana"]; $uniqueStrings = deduplicateStrings($strings); print_r($uniqueStrings); // Outputs: ['apple', 'banana', 'orange'] ?>

PHP deduplicate strings strong typing array manipulation