Examveda
Examveda

What will be the output of the following PHP code?
<?php
$arr = array ("picture1.JPG", "picture2.jpg", "Picture10.jpg", "picture20.jpg");
sort($arr);
print_r($arr);
?>

A. Array ( [0] => picture1.JPG [1] => Picture10.jpg [2] => picture2.jpg [3] => picture20.jpg )

B. Array ( [0] => picture1.JPG [1] => picture2.jpg [2] => Picture10.jpg [3] => picture20.jpg )

C. Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture2.jpg [3] => picture20.jpg )

D. Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture20.jpg [3] => picture2.jpg )

Answer: Option C

Solution(By Examveda Team)

While sorting each character is compared with the others and sorted using ascii values therefore we the sorted array to be like option c.

This Question Belongs to PHP >> Arrays

Join The Discussion

Related Questions on Arrays