ExamVeda
Login
Home
41
What will be the output of the following PHP code?
<?php
$fruits = array ("apple", "mango", "peach", "pear", "orange");
$subset = array_splice ($fruits, 2);
print_r ($fruits);
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
The array_splice() function removes all elements of an array found within a specified range.
42
What will be the output of the following PHP code?
<?php
$number = array ("4", "hello", 2);
echo (array_sum ($number));
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
The array_sum() function add all the values of the input array together, returning the final sum. If a string datatype is found, it’ll be ignored.
43
What will be the output of the following PHP code?
<?php
$array1 = array ("KA", "LA", "CA", "MA", "TA");
$array2 = array ("KA", "IA", "CA", "GA", "TA");
$inter = array_intersect ($array1, $array2);
print_r ($inter);
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
The array_intersect() function returns a key preserved array consisting only of those values present in the first array that are also present in each of the other input arrays.
44
Array values are keyed by ______ values (called indexed arrays) or using ______ values (called associative arrays). Of course, these key methods can be combined as well.
Discuss
Answer & Solution
Answer: Option E
No explanation is given for this question. Let's Discuss on Board
45
What will the following script output?
<?php
$array = array (1, 2, 3, 5, 8, 13, 21, 34, 55);
$sum = 0;
for ($i = 0; $i < 5; $i++) {
$sum += $array[$array[$i]];
}
echo $sum;
?>
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
46
What elements will the following script output?
<?php
$array = array (true => 'a', 1 => 'b');
var_dump ($array);
?>
Discuss
Answer & Solution
Answer: Option E
No explanation is given for this question. Let's Discuss on Board
47
Which array function checks if the specified key exists in the array?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
48
There are three different kind of arrays:
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
49
Absent any actual need for choosing one method over the other, does passing arrays by value to a read-only function reduce performance compared to passing them by reference?
Discuss
Answer & Solution
Answer: Option E
No explanation is given for this question. Let's Discuss on Board
50
Assume you would like to sort an array in ascending order by value while preserving key associations. Which of the following PHP sorting functions would you use?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board