Vidyalelo
PHP · all questions

Arrays
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

53

Questions

3/3

Page

Pick an option on a question to see the right answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
$number = array ("4", "hello", 2);
echo (array_sum ($number));
?>

Select an option to see the answer and solution.

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");
array1, $array2);
print_r ($inter);
?>

Select an option to see the answer and solution.

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.

Select an option to see the answer and solution.

What will the following script output?
<?php
$array = array (1, 2, 3, 5, 8, 13, 21, 34, 55);
$sum = 0;
for (i < 5; $i++) {
array[i]];
}
echo $sum;
?>

Select an option to see the answer and solution.

What elements will the following script output?
<?php
$array = array (true => 'a', 1 => 'b');
var_dump ($array);
?>

Select an option to see the answer and solution.

Which array function checks if the specified key exists in the array?

Select an option to see the answer and solution.

There are three different kind of arrays:

Select an option to see the answer and solution.

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?

Select an option to see the answer and solution.

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?

Select an option to see the answer and solution.

What function computes the difference of arrays?

Select an option to see the answer and solution.

What functions count elements in an array?
1. count
2. Sizeof
3. Array_Count
4. Count_array

Select an option to see the answer and solution.

What array will you get if you convert an object to an array?

Select an option to see the answer and solution.