Home / CSE / PHP - CS :: Arrays in php

CSE :: PHP - CS

  1. PHP’s numerically indexed array begin with position ______.

  2. A.

     1

    B.

     2

    C.

     0

    D.

     -1


  3. 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”);

  4. A.

     3 and 4

    B.

     2 and 3

    C.

     Only 1

    D.

     2, 3 and 4


  5. What will be the output of the following php code?

    <?php

    $states = array("karnataka" => array( "population" => "11,35,000", "captial" => "Bangalore"),"Tamil Nadu" => array( "population" => "17,90,000","captial" => "Chennai") );

    echo $states["karnataka"]["population"];

    ?>

  6. A.

     karnataka 11,35,000

    B.

     11,35,000

    C.

     population 11,35,000

    D.

     karnataka population


  7. Which function will return true if a variable is an array or false if it is not?

  8. A.

     this_array()

    B.

     is_array()

    C.

     do_array()

    D.

     in_array()


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

  10. A.

     array_unshift()

    B.

     into_array()

    C.

     inend_array()

    D.

     array_push()