Examveda
Examveda

What will be the output of the following PHP code?
<?php
$fruits = array ("mango", "apple", "peach", "pear");
$fruits = asort ($fruits);
printr ($fruits);
?>

A. Array ( [1] => apple [0] => mango [2] => peach [3] => pear )

B. Array ( [0] => apple [1] => mango [2] => peach [3] => pear )

C. Error

D. Array ( [1] => apple [0] => mango [3] => peach [2] => pear )

Answer: Option A

Solution(By Examveda Team)

The function asort() sorts the array in ascending order, except that the key/value corresponding is maintained.

This Question Belongs to PHP >> Arrays

Join The Discussion

Related Questions on Arrays