Q:

Write a PHP program to get a sorted array without preserving the keys

0

Write a PHP program to get a sorted array without preserving the keys

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$my_array = array("red", "black", "green", "black", "white", "yellow"); 

$sorted_unique_array = array_values(array_unique($my_array)); 

print_r($sorted_unique_array);
?>

Sample Output:

Array                                                       
(                                                           
    [0] => Red                                              
    [1] => Green                                            
    [2] => White                                            
    [3] => Black                                            
)                                                           
Array                                                       
(                                                           
    [0] => 100                                              
    [1] => 200                                              
    [2] => -10                                              
    [3] => 0                                                
)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now