Arrays(Computer Science > Php Program ) Questions and Answers
Question 1. PHP’s numerically indexed array begin with position ______.
1
2
0
-1
Explanation:-
Answer: Option C. -> 0
Question 2. Which of the following are correct ways of creating an array? 1. state[0] = “karnataka”; 2. $state[] = array(“karnataka”); 3. $state[0] = “karnataka”; 4. $state = array(“karnataka”);
3 and 4
2 and 3
Only 1
2, 3 and 4
Explanation:-
Answer: Option A. -> 3 and 4
Question 3. Which function will return true if a variable is an array or false if it is not?
this_array()
is_array()
do_array()
in_array()
Explanation:-
Answer: Option B. -> is_array()
Question 4. What will be the output of the following php code?
karnataka 11,35,000
11,35,000
population 11,35,000
karnataka population
Explanation:-
Answer: Option B. -> 11,35,000
Question 5. Which in-built function will add a value to the end of an array?
array_unshift()
into_array()
inend_array()
array_push()
Explanation:-
Answer: Option D. -> array_push()
Question 6. What will be the output of the following PHP code?
True
1
False
2
Explanation:-
Answer: Option D. -> 2
Question 7. What will be the output of the following PHP code?
orangebanana
appleorange
orangeorange
appleapple
Explanation:-
Answer: Option A. -> orangebanana
Question 8. Which function can be used to move the pointer to the previous array position?
last()
before()
prev()
previous()
Explanation:-
Answer: Option C. -> prev()
Question 9. What will be the output of the following PHP code?
3
4
5
6
Explanation:-
Answer: Option D. -> 6
Question 10. Which function returns an array consisting of associative key/value pairs?