Q:

Write a PHP script to lower-case and upper-case, all elements in an array

0

Write a PHP script to lower-case and upper-case, all elements in an array

All Answers

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

<?php
$colors = array( "Red", "Green", "Black", "White"); 
print_r($colors);

$lower_colors = array_map('strtolower', $colors);
print_r($lower_colors);
$upper_colors = array_map('strtoupper', $colors);
print_r($upper_colors);
?>

Sample Output:

Array                                                       
(                                                           
    [0] => Red                                              
    [1] => Green                                            
    [2] => Black                                            
    [3] => White                                            
)                                                           
Array                                                       
(                                                           
    [0] => red                                              
    [1] => green                                            
    [2] => black                                            
    [3] => white                                            
)                                                           
Array                                                       
(                                                           
    [0] => RED                                              
    [1] => GREEN                                            
    [2] => BLACK                                            
    [3] => WHITE                                            
)

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