Complete the code to remove duplicate values from the array.
<?php $numbers = [1, 2, 2, 3, 4, 4, 5]; $unique = [1]($numbers); print_r($unique); ?>
The array_unique function removes duplicate values from an array.
Complete the code to flip keys and values of the array.
<?php $colors = ['red', 'green', 'blue']; $flipped = [1]($colors); print_r($flipped); ?>
The array_flip function swaps the keys and values of an array.
Fix the error in the code to correctly remove duplicates and flip the array.
<?php $items = ['a', 'b', 'a', 'c']; $unique = [1]($items); $flipped = array_flip($unique); print_r($flipped); ?>
First remove duplicates with array_unique, then flip keys and values.
Fill both blanks to create an array of unique values and then flip keys and values.
<?php $fruits = ['apple', 'banana', 'apple', 'orange']; $unique = [1]($fruits); $flipped = [2]($unique); print_r($flipped); ?>
Use array_unique to remove duplicates, then array_flip to swap keys and values.
Fill all three blanks to remove duplicates, flip the array, and then get the keys of the flipped array.
<?php $letters = ['x', 'y', 'x', 'z']; $unique = [1]($letters); $flipped = [2]($unique); $keys = [3]($flipped); print_r($keys); ?>
First remove duplicates with array_unique, then flip keys and values with array_flip, and finally get the keys with array_keys.