Arrays
1.

PHP’s numerically indexed array begin with position ___________

A.  

1

B.  

2

C.  

0

D.  

-1

2.

Which of the following are correct ways of creating an array?

i) state[0] = "karnataka";
ii) $state[] = array("karnataka");
iii) $state[0] = "karnataka";
iv)  $state = array("karnataka");
A.  

iii) and iv)

B.  

ii) and iii)

C.  

Only i)

D.  

ii), iii) and iv)

3.

What will be the output of the following PHP code?

 <?php
    $states = array("Karnataka" => array
    ("population" => "11,35,000", "capital" => "Bangalore"),
    "Tamil Nadu" => array( "population" => "17,90,000",
    "capital" => "Chennai") );
    echo $states["Karnataka"]["population"];
    ?>
A.  

Karnataka 11,35,000

B.  

11,35,000

C.  

population 11,35,000

D.  

Karnataka population

4.

Which of the following PHP function will return true if a variable is an array or false if it is not an array?

A.  

this_array()

B.  

is_array()

C.  

do_array()

D.  

in_array()

5.

Which in-built function will add a value to the end of an array?

A.  

array_unshift()

B.  

into_array()

C.  

inend_array()

D.  

array_push()

6.

What will be the output of the following PHP code?

 <?php
    $state = array ("Karnataka", "Goa", "Tamil Nadu",
    "Andhra Pradesh");
    echo (array_search ("Tamil Nadu", $state) );
    ?>
A.  

True

B.  

1

C.  

False

D.  

2

7.

What will be the output of the following PHP code?

 <?php
    $fruits = array ("apple", "orange", "banana");
    echo (next($fruits));	
    echo (next($fruits));
    ?>
A.  

orangebanana

B.  

appleorange

C.  

orangeorange

D.  

appleapple

8.

What will be the output of the following PHP code?

 <?php
    $fruits = array ("apple", "orange", "banana");
    echo (next($fruits));	
    echo (next($fruits));
    ?>
A.  

orangebanana

B.  

appleorange

C.  

orangeorange

D.  

appleapple

9.

Which of the following function is used to get the value of the previous element in an array?

A.  

last()

B.  

before()

C.  

prev()

D.  

previous()

10.

What will be the output of the following PHP code?

  <?php
    $fruits = array ("apple", "orange", array ("pear", "mango"),
    "banana");
    echo (count($fruits, 1));
    ?>
A.  

3

B.  

4

C.  

5

D.  

6