Join Now
Home Aptitude Reasoning DI VA GK CA CA Hindi Quiz Placements
What is the output of the following PHP code snippet?
<?php$array = ["apple", "banana", "orange"];$lengths = array_map('strlen', $array);print_r($lengths);?>
["a", "b", "o"]
[5, 6, 6]
["apple", "banana", "orange"]
None of the above
<?php$array1 = ["apple", "banana"];$array2 = ["orange", "grape"];$result = array_intersect($array1, $array2);print_r($result);?>
["apple", "banana"]
["orange", "grape"]
[]
<?php$array = ["apple", "banana", "orange"];$last_element = end($array);echo $last_element;?>
apple
banana
orange
0
<?php$array = ["apple", "banana", "orange"];$subset = array_slice($array, 1, 2);print_r($subset);?>
["apple"]
["banana"]
["orange"]
["banana", "orange"]
foreach()
for()
while()
do-while()
in_array()
array_exists()
value_in_array()
array_contains()
<?php$array = ["apple", "banana", "orange"];echo count($array);?>
1
2
3
$array[0]
$array[1]
$array[first]
$array["first"]
<?php$array = ["apple", "banana", "orange"];$new_array = array_values($array);print_r($new_array);?>
[0 => "apple", 1 => "banana", 2 => "orange"]
[1 => "apple", 2 => "banana", 3 => "orange"]
sort()
asort()
ksort()
rsort()